From f9c3adeae04dbc42ee10242d7286705f82448be7 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 21 Aug 2015 15:20:08 -0700 Subject: [PATCH] Update LKG --- lib/lib.core.d.ts | 2665 ++++++- lib/lib.core.es6.d.ts | 5348 +++++++------ lib/lib.d.ts | 475 +- lib/lib.dom.d.ts | 2337 +----- lib/lib.es6.d.ts | 5384 +++++++------ lib/lib.webworker.d.ts | 2450 +----- lib/tsc.js | 9082 +++++++++++---------- lib/tsserver.js | 12144 +++++++++++++++------------- lib/typescript.d.ts | 638 +- lib/typescript.js | 14314 +++++++++++++++++++--------------- lib/typescriptServices.d.ts | 639 +- lib/typescriptServices.js | 14314 +++++++++++++++++++--------------- 12 files changed, 36957 insertions(+), 32833 deletions(-) diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index a265b5c2a95..b588c9fdb77 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,4 +1196,2645 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + 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. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index 48d02ec1465..fd115497f8a 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,7 +1196,2648 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + 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. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; declare type PropertyKey = string | number | symbol; interface Symbol { @@ -1286,8 +3927,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -1297,8 +3938,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -1369,16 +4010,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -1447,15 +4091,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -1576,7 +4229,7 @@ interface String { * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ - contains(searchString: string, position?: number): boolean; + includes(searchString: string, position?: number): boolean; /** * Returns true if the sequence of elements of searchString converted to a String is the @@ -1607,6 +4260,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -1818,37 +4506,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -1877,6 +4604,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -1966,440 +4697,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - 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; - [Symbol.toStringTag]: string; } -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. */ interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -2407,289 +4733,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -2697,289 +4765,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -2987,289 +4801,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -3277,289 +4837,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -3567,289 +4869,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -3857,289 +4901,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -4147,289 +4933,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -4437,289 +4965,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -4727,9 +4997,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -4754,9 +5023,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -4857,20 +5126,3 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} \ No newline at end of file diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 430d8279de4..7a411e002fa 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,11 +1196,13 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// /** * Represents a raw buffer of binary data, which is used to store data for the @@ -1253,14 +1255,14 @@ interface DataView { * 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; + 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; + getFloat64(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int8 value at the specified byte offset from the start of the view. There is @@ -1274,13 +1276,13 @@ interface DataView { * 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; + 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; + getInt32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Uint8 value at the specified byte offset from the start of the view. There is @@ -1294,14 +1296,14 @@ interface DataView { * 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; + 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; + getUint32(byteOffset: number, littleEndian?: boolean): number; /** * Stores an Float32 value at the specified byte offset from the start of the view. @@ -1310,7 +1312,7 @@ interface DataView { * @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; + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Float64 value at the specified byte offset from the start of the view. @@ -1319,7 +1321,7 @@ interface DataView { * @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; + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int8 value at the specified byte offset from the start of the view. @@ -1335,7 +1337,7 @@ interface DataView { * @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; + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int32 value at the specified byte offset from the start of the view. @@ -1344,7 +1346,7 @@ interface DataView { * @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; + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint8 value at the specified byte offset from the start of the view. @@ -1360,7 +1362,7 @@ interface DataView { * @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; + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint32 value at the specified byte offset from the start of the view. @@ -1369,7 +1371,7 @@ interface DataView { * @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; + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } interface DataViewConstructor { @@ -1576,7 +1578,7 @@ interface Int8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1625,8 +1627,7 @@ interface Int8Array { interface Int8ArrayConstructor { prototype: Int8Array; new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; + new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; /** @@ -1639,6 +1640,15 @@ interface Int8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + } declare var Int8Array: Int8ArrayConstructor; @@ -1841,7 +1851,7 @@ interface Uint8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1891,8 +1901,7 @@ interface Uint8Array { interface Uint8ArrayConstructor { prototype: Uint8Array; new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; + new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; /** @@ -1905,9 +1914,291 @@ interface Uint8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + } declare var Uint8Array: Uint8ArrayConstructor; +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. @@ -2107,7 +2398,7 @@ interface Int16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2157,8 +2448,7 @@ interface Int16Array { interface Int16ArrayConstructor { prototype: Int16Array; new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; + new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; /** @@ -2171,6 +2461,15 @@ interface Int16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + } declare var Int16Array: Int16ArrayConstructor; @@ -2373,7 +2672,7 @@ interface Uint16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2423,8 +2722,7 @@ interface Uint16Array { interface Uint16ArrayConstructor { prototype: Uint16Array; new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; + new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; /** @@ -2437,6 +2735,15 @@ interface Uint16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + } declare var Uint16Array: Uint16ArrayConstructor; /** @@ -2638,7 +2945,7 @@ interface Int32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2688,8 +2995,7 @@ interface Int32Array { interface Int32ArrayConstructor { prototype: Int32Array; new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; + new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; /** @@ -2702,6 +3008,14 @@ interface Int32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; @@ -2904,7 +3218,7 @@ interface Uint32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2954,8 +3268,7 @@ interface Uint32Array { interface Uint32ArrayConstructor { prototype: Uint32Array; new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; + new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; /** @@ -2968,6 +3281,14 @@ interface Uint32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; @@ -3170,7 +3491,7 @@ interface Float32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -3220,8 +3541,7 @@ interface Float32Array { interface Float32ArrayConstructor { prototype: Float32Array; new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; + new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; /** @@ -3234,6 +3554,15 @@ interface Float32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + } declare var Float32Array: Float32ArrayConstructor; @@ -3436,7 +3765,7 @@ interface Float64Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float64Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -3486,8 +3815,7 @@ interface Float64Array { interface Float64ArrayConstructor { prototype: Float64Array; new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; + new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; /** @@ -3500,8 +3828,17 @@ interface Float64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// +declare var Float64Array: Float64ArrayConstructor; +///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -6135,7 +6472,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -6706,7 +7043,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -10541,7 +10878,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10662,7 +10999,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -10692,11 +11029,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -15638,7 +15978,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -15845,7 +16185,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16115,7 +16455,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16271,7 +16611,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16288,11 +16628,17 @@ interface NodeListOf extends NodeList { [index: number]: TNode; } + interface BlobPropertyBag { type?: string; endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } @@ -16453,7 +16799,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; @@ -16628,7 +16974,8 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 5ec268b2fd5..896db2d55ef 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -14,2311 +14,7 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - 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. - */ -interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} -interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; -} -declare var Int8Array: Int8ArrayConstructor; - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; -} -declare var Uint8Array: Uint8ArrayConstructor; - -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; -} -declare var Int16Array: Int16ArrayConstructor; - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; -} -declare var Uint16Array: Uint16ArrayConstructor; -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; -} -declare var Int32Array: Int32ArrayConstructor; - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; -} -declare var Uint32Array: Uint32ArrayConstructor; - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ -interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; -} -declare var Float32Array: Float32ArrayConstructor; - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -4952,7 +2648,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -5523,7 +3219,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -9358,7 +7054,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9479,7 +7175,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -9509,11 +7205,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -14455,7 +12154,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -14662,7 +12361,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -14932,7 +12631,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -15088,7 +12787,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -15105,11 +12804,17 @@ interface NodeListOf extends NodeList { [index: number]: TNode; } + interface BlobPropertyBag { type?: string; endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } @@ -15270,7 +12975,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; @@ -15445,4 +13150,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 6c06cc08dc7..02b89b3a2ba 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,7 +1196,2648 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + 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. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; declare type PropertyKey = string | number | symbol; interface Symbol { @@ -1286,8 +3927,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -1297,8 +3938,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -1369,16 +4010,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -1447,15 +4091,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -1576,7 +4229,7 @@ interface String { * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ - contains(searchString: string, position?: number): boolean; + includes(searchString: string, position?: number): boolean; /** * Returns true if the sequence of elements of searchString converted to a String is the @@ -1607,6 +4260,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -1818,37 +4506,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -1877,6 +4604,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -1966,440 +4697,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - 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; - [Symbol.toStringTag]: string; } -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. */ interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -2407,289 +4733,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -2697,289 +4765,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -2987,289 +4801,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -3277,289 +4837,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -3567,289 +4869,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -3857,289 +4901,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -4147,289 +4933,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -4437,289 +4965,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -4727,9 +4997,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -4754,9 +5023,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -4857,23 +5126,7 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -}///////////////////////////// +///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -7507,7 +7760,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -8078,7 +8331,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -11913,7 +12166,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12034,7 +12287,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12064,11 +12317,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -17010,7 +17266,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -17217,7 +17473,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17487,7 +17743,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17643,7 +17899,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17660,11 +17916,17 @@ interface NodeListOf extends NodeList { [index: number]: TNode; } + interface BlobPropertyBag { type?: string; endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } @@ -17825,7 +18087,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; @@ -18000,7 +18262,8 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;interface DOMTokenList { +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +interface DOMTokenList { [Symbol.iterator](): IterableIterator; } @@ -18011,6 +18274,7 @@ interface NodeList { interface NodeListOf { [Symbol.iterator](): IterableIterator } + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index d9e8a2ab333..ed9f18e8dae 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -14,2311 +14,7 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - 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. - */ -interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} -interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; -} -declare var Int8Array: Int8ArrayConstructor; - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; -} -declare var Uint8Array: Uint8ArrayConstructor; - -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; -} -declare var Int16Array: Int16ArrayConstructor; - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; -} -declare var Uint16Array: Uint16ArrayConstructor; -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; -} -declare var Int32Array: Int32ArrayConstructor; - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; -} -declare var Uint32Array: Uint32ArrayConstructor; - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ -interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; -} -declare var Float32Array: Float32ArrayConstructor; - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -2496,10 +192,28 @@ interface Date { /// IE Worker APIs ///////////////////////////// +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; +} + interface EventListener { (evt: Event): void; } +interface AudioBuffer { + duration: number; + length: number; + numberOfChannels: number; + sampleRate: number; + getChannelData(channel: number): any; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + interface Blob { size: number; type: string; @@ -2553,6 +267,21 @@ declare var Console: { new(): Console; } +interface Coordinates { + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + latitude: number; + longitude: number; + speed: number; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + interface DOMError { name: string; toString(): string; @@ -2703,7 +432,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -2774,7 +503,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -2895,7 +624,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -2925,11 +654,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface MSApp { clearTemporaryWebDataAsync(): MSAppAsyncOperation; createBlobFromRandomAccessStream(type: string, seeker: any): Blob; @@ -2953,6 +685,29 @@ interface MSApp { } declare var MSApp: MSApp; +interface MSAppAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; +} + interface MSBlobBuilder { append(data: any, endings?: string): void; getBlob(contentType?: string): Blob; @@ -2989,6 +744,18 @@ declare var MSStreamReader: { new(): MSStreamReader; } +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + interface MessageChannel { port1: MessagePort; port2: MessagePort; @@ -3026,6 +793,33 @@ declare var MessagePort: { new(): MessagePort; } +interface Position { + coords: Coordinates; + timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + interface ProgressEvent extends Event { lengthComputable: boolean; loaded: number; @@ -3113,7 +907,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -3135,6 +929,15 @@ declare var XMLHttpRequest: { create(): XMLHttpRequest; } +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequestUpload: { + prototype: XMLHttpRequestUpload; + new(): XMLHttpRequestUpload; +} + interface AbstractWorker { onerror: (ev: Event) => any; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; @@ -3154,7 +957,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -3195,7 +998,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -3281,17 +1084,16 @@ interface WorkerUtils extends Object, WindowBase64 { } -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - interface BlobPropertyBag { type?: string; endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } @@ -3299,7 +1101,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } interface PositionCallback { (position: Position): void; @@ -3313,11 +1115,11 @@ interface MediaQueryListListener { interface MSLaunchUriCallback { (): void; } -interface FrameRequestCallback { - (time: number): void; +interface MSUnsafeFunctionCallback { + (): any; } -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; } interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; @@ -3354,4 +1156,4 @@ declare function postMessage(data: any): void; declare var console: Console; declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; diff --git a/lib/tsc.js b/lib/tsc.js index 185aca1ef44..eb2a963b828 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -57,6 +57,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -78,6 +79,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; function forEach(array, callback) { @@ -495,7 +499,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -649,7 +653,7 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -864,7 +868,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -892,7 +896,7 @@ var ts; } function writeFile(fileName, data, writeByteOrderMark) { if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -933,7 +937,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -955,7 +959,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -992,7 +995,7 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { return getNodeSystem(); } else { @@ -1255,6 +1258,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -1294,7 +1298,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -1425,6 +1429,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, 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}'." }, @@ -1504,20 +1510,11 @@ var ts; 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}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_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 'isolatedModules' 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." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, 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." }, @@ -1568,7 +1565,6 @@ var ts; 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'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, @@ -1613,7 +1609,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -1621,123 +1618,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112, - "any": 114, - "as": 113, - "boolean": 117, - "break": 67, - "case": 68, - "catch": 69, - "class": 70, - "continue": 72, - "const": 71, - "constructor": 118, - "debugger": 73, - "declare": 119, - "default": 74, - "delete": 75, - "do": 76, - "else": 77, - "enum": 78, - "export": 79, - "extends": 80, - "false": 81, - "finally": 82, - "for": 83, - "from": 130, - "function": 84, - "get": 120, - "if": 85, - "implements": 103, - "import": 86, - "in": 87, - "instanceof": 88, - "interface": 104, - "is": 121, - "let": 105, - "module": 122, - "namespace": 123, - "new": 89, - "null": 90, - "number": 125, - "package": 106, - "private": 107, - "protected": 108, - "public": 109, - "require": 124, - "return": 91, - "set": 126, - "static": 110, - "string": 127, - "super": 92, - "switch": 93, - "symbol": 128, - "this": 94, - "throw": 95, - "true": 96, - "try": 97, - "type": 129, - "typeof": 98, - "var": 99, - "void": 100, - "while": 101, - "with": 102, - "yield": 111, - "async": 115, - "await": 116, - "of": 131, - "{": 14, - "}": 15, - "(": 16, - ")": 17, - "[": 18, - "]": 19, - ".": 20, - "...": 21, - ";": 22, - ",": 23, - "<": 24, - ">": 26, - "<=": 27, - ">=": 28, - "==": 29, - "!=": 30, - "===": 31, - "!==": 32, - "=>": 33, - "+": 34, - "-": 35, - "*": 36, - "/": 37, - "%": 38, - "++": 39, - "--": 40, - "<<": 41, - ">": 42, - ">>>": 43, - "&": 44, - "|": 45, - "^": 46, - "!": 47, - "~": 48, - "&&": 49, - "||": 50, - "?": 51, - ":": 52, - "=": 54, - "+=": 55, - "-=": 56, - "*=": 57, - "/=": 58, - "%=": 59, - "<<=": 60, - ">>=": 61, - ">>>=": 62, - "&=": 63, - "|=": 64, - "^=": 65, - "@": 53 + "abstract": 113, + "any": 115, + "as": 114, + "boolean": 118, + "break": 68, + "case": 69, + "catch": 70, + "class": 71, + "continue": 73, + "const": 72, + "constructor": 119, + "debugger": 74, + "declare": 120, + "default": 75, + "delete": 76, + "do": 77, + "else": 78, + "enum": 79, + "export": 80, + "extends": 81, + "false": 82, + "finally": 83, + "for": 84, + "from": 131, + "function": 85, + "get": 121, + "if": 86, + "implements": 104, + "import": 87, + "in": 88, + "instanceof": 89, + "interface": 105, + "is": 122, + "let": 106, + "module": 123, + "namespace": 124, + "new": 90, + "null": 91, + "number": 126, + "package": 107, + "private": 108, + "protected": 109, + "public": 110, + "require": 125, + "return": 92, + "set": 127, + "static": 111, + "string": 128, + "super": 93, + "switch": 94, + "symbol": 129, + "this": 95, + "throw": 96, + "true": 97, + "try": 98, + "type": 130, + "typeof": 99, + "var": 100, + "void": 101, + "while": 102, + "with": 103, + "yield": 112, + "async": 116, + "await": 117, + "of": 132, + "{": 15, + "}": 16, + "(": 17, + ")": 18, + "[": 19, + "]": 20, + ".": 21, + "...": 22, + ";": 23, + ",": 24, + "<": 25, + ">": 27, + "<=": 28, + ">=": 29, + "==": 30, + "!=": 31, + "===": 32, + "!==": 33, + "=>": 34, + "+": 35, + "-": 36, + "*": 37, + "/": 38, + "%": 39, + "++": 40, + "--": 41, + "<<": 42, + ">": 43, + ">>>": 44, + "&": 45, + "|": 46, + "^": 47, + "!": 48, + "~": 49, + "&&": 50, + "||": 51, + "?": 52, + ":": 53, + "=": 55, + "+=": 56, + "-=": 57, + "*=": 58, + "/=": 59, + "%=": 60, + "<<=": 61, + ">>=": 62, + ">>>=": 63, + "&=": 64, + "|=": 65, + "^=": 66, + "@": 54 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1838,6 +1835,7 @@ var ts; var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -1903,6 +1901,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1959,12 @@ var ts; continue; } break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2010,6 +2016,16 @@ var ts; } return pos; } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -2091,6 +2107,12 @@ var ts; return getCommentRanges(text, pos, true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 36 || ch === 95 || @@ -2124,8 +2146,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 || token > 102; }, - isReservedWord: function () { return token >= 67 && token <= 102; }, + isIdentifier: function () { return token === 67 || token > 103; }, + isReservedWord: function () { return token >= 68 && token <= 103; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2265,20 +2287,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 : 12; + resultingToken = startedWithBacktick ? 12 : 13; break; } if (currChar === 92) { @@ -2439,7 +2461,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66; + return token = 67; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2471,6 +2493,15 @@ var ts; return token = 1; } var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } switch (ch) { case 10: case 13: @@ -2505,66 +2536,66 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } - return pos++, token = 47; + return pos++, token = 48; case 34: case 39: tokenValue = scanString(); - return token = 8; + return token = 9; case 96: return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } - return pos++, token = 38; + return pos++, token = 39; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 40: - return pos++, token = 16; - case 41: return pos++, token = 17; + case 41: + return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 39; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; - } - return pos++, token = 34; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 40; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 56; } return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 36; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 21; + return pos += 3, token = 22; } - return pos++, token = 20; + return pos++, token = 21; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -2608,9 +2639,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2620,7 +2651,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; @@ -2630,7 +2661,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; @@ -2640,11 +2671,11 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7; + return token = 8; } case 49: case 50: @@ -2656,11 +2687,11 @@ var ts; case 56: case 57: tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; case 58: - return pos++, token = 52; + return pos++, token = 53; case 59: - return pos++, token = 22; + return pos++, token = 23; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2668,22 +2699,22 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 27; + return pos += 2, token = 28; } if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { - return pos += 2, token = 25; + return pos += 2, token = 26; } - return pos++, token = 24; + return pos++, token = 25; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2691,19 +2722,19 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 33; + return pos += 2, token = 34; } - return pos++, token = 54; + return pos++, token = 55; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2711,37 +2742,37 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } - return pos++, token = 26; + return pos++, token = 27; case 63: - return pos++, token = 51; + return pos++, token = 52; case 91: - return pos++, token = 18; - case 93: return pos++, token = 19; + case 93: + return pos++, token = 20; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 66; + } + return pos++, token = 47; + case 123: + return pos++, token = 15; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 51; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 65; } return pos++, token = 46; - case 123: - return pos++, token = 14; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 50; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - return pos++, token = 45; case 125: - return pos++, token = 15; + return pos++, token = 16; case 126: - return pos++, token = 48; + return pos++, token = 49; case 64: - return pos++, token = 53; + return pos++, token = 54; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2777,27 +2808,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26) { + if (token === 27) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 62; + return pos += 3, token = 63; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } - return pos++, token = 42; + return pos++, token = 43; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 28; + return pos++, token = 29; } } return token; } function reScanSlashToken() { - if (token === 37 || token === 58) { + if (token === 38 || token === 59) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2836,12 +2867,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9; + token = 10; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 15, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -2858,14 +2889,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 25; + return token = 26; } pos++; - return token = 24; + return token = 25; } if (char === 123) { pos++; - return token = 14; + return token = 15; } while (pos < end) { pos++; @@ -2874,10 +2905,10 @@ var ts; break; } } - return token = 233; + return token = 234; } function scanJsxIdentifier() { - if (token === 66) { + if (token === 67) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -2949,16 +2980,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 212 || node.kind === 213) { + if (node.kind === 213 || node.kind === 214) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { + else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { return 0; } - else if (node.kind === 216) { + else if (node.kind === 217) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -2974,7 +3005,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -3026,10 +3057,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 && node.name.kind === 8) { - return '"' + node.name.text + '"'; + if (node.kind === 216 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133) { + if (node.name.kind === 134) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3037,22 +3068,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141: + case 142: return "__constructor"; - case 149: - case 144: - return "__call"; case 150: case 145: - return "__new"; + return "__call"; + case 151: case 146: + return "__new"; + case 147: return "__index"; - case 225: + case 226: return "__export"; - case 224: + case 225: return node.isExportEquals ? "export=" : "default"; - case 210: case 211: + case 212: return node.flags & 1024 ? "default" : undefined; } } @@ -3094,7 +3125,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { + if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3140,37 +3171,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183: - case 211: + case 184: case 212: - case 214: - case 152: - case 162: + case 213: + case 215: + case 153: + case 163: return 1; - case 144: case 145: case 146: - case 140: - case 139: - case 210: + case 147: case 141: + case 140: + case 211: case 142: case 143: - case 149: + case 144: case 150: - case 170: + case 151: case 171: - case 215: - case 245: - case 213: + case 172: + case 216: + case 246: + case 214: return 5; - case 241: - case 196: + case 242: case 197: case 198: - case 217: + case 199: + case 218: return 2; - case 189: + case 190: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -3186,33 +3217,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 215: + case 216: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245: + case 246: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183: - case 211: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 214: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 162: + case 184: case 212: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 215: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 153: + case 163: + case 213: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149: case 150: - case 144: + case 151: case 145: case 146: - case 140: - case 139: + case 147: case 141: + case 140: case 142: case 143: - case 210: - case 170: + case 144: + case 211: case 171: - case 213: + case 172: + case 214: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3236,11 +3267,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 ? node : node.body; - if (body.kind === 245 || body.kind === 216) { + var body = node.kind === 246 ? node : node.body; + if (body.kind === 246 || body.kind === 217) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 || stat.kind === 224) { + if (stat.kind === 226 || stat.kind === 225) { return true; } } @@ -3257,7 +3288,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8) { + if (node.name.kind === 9) { declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -3267,12 +3298,17 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512, 106639); - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; } else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -3290,11 +3326,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66) { + if (prop.name.kind !== 67) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 + var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -3316,10 +3352,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215: + case 216: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245: + case 246: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3337,8 +3373,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 && - node.originalKeywordKind <= 111 && + node.originalKeywordKind >= 104 && + node.originalKeywordKind <= 112 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -3365,17 +3401,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 66) { + if (inStrictMode && node.expression.kind === 67) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66) { + if (name && name.kind === 67) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -3409,7 +3445,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 39 || node.operator === 40) { + if (node.operator === 40 || node.operator === 41) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -3438,17 +3474,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245: - case 216: + case 246: + case 217: updateStrictModeStatementList(node.statements); return; - case 189: + case 190: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211: - case 183: + case 212: + case 184: inStrictMode = true; return; } @@ -3467,106 +3503,106 @@ var ts; } function isUseStrictPrologueDirective(node) { var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66: + case 67: return checkStrictModeIdentifier(node); - case 178: + case 179: return checkStrictModeBinaryExpression(node); - case 241: - return checkStrictModeCatchClause(node); - case 172: - return checkStrictModeDeleteExpression(node); - case 7: - return checkStrictModeNumericLiteral(node); - case 177: - return checkStrictModePostfixUnaryExpression(node); - case 176: - return checkStrictModePrefixUnaryExpression(node); - case 202: - return checkStrictModeWithStatement(node); - case 134: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 135: - return bindParameter(node); - case 208: - case 160: - return bindVariableDeclarationOrBindingElement(node); - case 138: - case 137: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 242: + return checkStrictModeCatchClause(node); + case 173: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 178: + return checkStrictModePostfixUnaryExpression(node); + case 177: + return checkStrictModePrefixUnaryExpression(node); + case 203: + return checkStrictModeWithStatement(node); + case 135: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 136: + return bindParameter(node); + case 209: + case 161: + return bindVariableDeclarationOrBindingElement(node); + case 139: + case 138: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 243: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 244: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 245: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 144: case 145: case 146: + case 147: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 141: case 140: - case 139: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 210: + case 211: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 141: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 142: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 143: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 144: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 149: case 150: + case 151: return bindFunctionOrConstructorType(node); - case 152: + case 153: return bindAnonymousDeclaration(node, 2048, "__type"); - case 162: + case 163: return bindObjectLiteralExpression(node); - case 170: case 171: + case 172: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 183: - case 211: - return bindClassLikeDeclaration(node); + case 184: case 212: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 213: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 214: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 215: + return bindEnumDeclaration(node); + case 216: return bindModuleDeclaration(node); - case 218: - case 221: - case 223: - case 227: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 220: - return bindImportClause(node); - case 225: - return bindExportDeclaration(node); + case 219: + case 222: case 224: + case 228: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 221: + return bindImportClause(node); + case 226: + return bindExportDeclaration(node); + case 225: return bindExportAssignment(node); - case 245: + case 246: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 66) { + else if (node.expression.kind === 67) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3587,7 +3623,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -3637,7 +3673,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 141 && + node.parent.kind === 142 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -3699,6 +3735,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; function containsParseError(node) { aggregateChildData(node); return (node.parserContextFlags & 64) !== 0; @@ -3715,7 +3782,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3791,7 +3858,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -3806,15 +3873,15 @@ var ts; return current; } switch (current.kind) { - case 245: - case 217: - case 241: - case 215: - case 196: + case 246: + case 218: + case 242: + case 216: case 197: case 198: + case 199: return current; - case 189: + case 190: if (!isFunctionLike(current.parent)) { return current; } @@ -3825,9 +3892,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 && + declaration.kind === 209 && declaration.parent && - declaration.parent.kind === 241; + declaration.parent.kind === 242; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3863,22 +3930,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245: + case 246: 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 208: - case 160: - case 211: - case 183: + case 209: + case 161: case 212: + case 184: + case 213: + case 216: case 215: - case 214: - case 244: - case 210: - case 170: + case 245: + case 211: + case 171: errorNode = node.name; break; } @@ -3900,11 +3967,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 && isConst(node); + return node.kind === 215 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 || isBindingPattern(node))) { + while (node && (node.kind === 161 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3912,14 +3979,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208) { + if (node.kind === 209) { node = node.parent; } - if (node && node.kind === 209) { + if (node && node.kind === 210) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190) { + if (node && node.kind === 191) { flags |= node.flags; } return flags; @@ -3934,20 +4001,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 && node.expression.kind === 8; + return node.kind === 193 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 135 || node.kind === 134) { - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 || node.kind === 135) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && @@ -3957,68 +4022,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 <= node.kind && node.kind <= 157) { + if (149 <= node.kind && node.kind <= 158) { return true; } switch (node.kind) { - case 114: - case 125: - case 127: - case 117: + case 115: + case 126: case 128: + case 118: + case 129: return true; - case 100: - return node.parent.kind !== 174; - case 8: - return node.parent.kind === 135; - case 185: + case 101: + return node.parent.kind !== 175; + case 9: + return node.parent.kind === 136; + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 66: - if (node.parent.kind === 132 && node.parent.right === node) { + case 67: + if (node.parent.kind === 133 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 && node.parent.name === node) { + else if (node.parent.kind === 164 && node.parent.name === node) { node = node.parent; } - case 132: - case 163: - ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 133: + case 164: + ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151) { + if (parent_1.kind === 152) { return false; } - if (148 <= parent_1.kind && parent_1.kind <= 157) { + if (149 <= parent_1.kind && parent_1.kind <= 158) { return true; } switch (parent_1.kind) { - case 185: + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134: - return node === parent_1.constraint; - case 138: - case 137: case 135: - case 208: + return node === parent_1.constraint; + case 139: + case 138: + case 136: + case 209: return node === parent_1.type; - case 210: - case 170: + case 211: case 171: + case 172: + case 142: case 141: case 140: - case 139: - case 142: case 143: - return node === parent_1.type; case 144: + return node === parent_1.type; case 145: case 146: + case 147: return node === parent_1.type; - case 168: + case 169: return node === parent_1.type; - case 165: case 166: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 167: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 168: return false; } } @@ -4029,23 +4094,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201: + case 202: return visitor(node); - case 217: - case 189: - case 193: + case 218: + case 190: case 194: case 195: case 196: case 197: case 198: - case 202: + case 199: case 203: - case 238: - case 239: case 204: - case 206: - case 241: + case 239: + case 240: + case 205: + case 207: + case 242: return ts.forEachChild(node, traverse); } } @@ -4055,23 +4120,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181: + case 182: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214: - case 212: case 215: case 213: - case 211: - case 183: + case 216: + case 214: + case 212: + case 184: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133) { + if (name_5 && name_5.kind === 134) { traverse(name_5.expression); return; } @@ -4086,14 +4151,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160: - case 244: - case 135: - case 242: - case 138: - case 137: + case 161: + case 245: + case 136: case 243: - case 208: + case 139: + case 138: + case 244: + case 209: return true; } } @@ -4101,41 +4166,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 || node.kind === 143); + return node && (node.kind === 143 || node.kind === 144); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 || node.kind === 183); + return node && (node.kind === 212 || node.kind === 184); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141: - case 170: - case 210: - case 171: - case 140: - case 139: case 142: + case 171: + case 211: + case 172: + case 141: + case 140: case 143: case 144: case 145: case 146: - case 149: + case 147: case 150: + case 151: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141: + case 140: + case 142: + case 143: + case 144: + case 211: + case 171: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 && isFunctionLike(node.parent); + return node && node.kind === 190 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 && node.parent.kind === 162; + return node && node.kind === 141 && node.parent.kind === 163; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4163,36 +4242,36 @@ var ts; return undefined; } switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 171: + case 172: if (!includeArrowFunctions) { continue; } - case 210: - case 170: - case 215: - case 138: - case 137: - case 140: + case 211: + case 171: + case 216: case 139: + case 138: case 141: + case 140: case 142: case 143: - case 214: - case 245: + case 144: + case 215: + case 246: return node; } } @@ -4204,33 +4283,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 210: - case 170: + case 211: case 171: + case 172: if (!includeFunctions) { continue; } - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: return node; } } @@ -4239,12 +4318,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148: + case 149: return node.typeName; - case 185: + case 186: return node.expression; - case 66: - case 132: + case 67: + case 133: return node; } } @@ -4252,7 +4331,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167) { + if (node.kind === 168) { return node.tag; } return node.expression; @@ -4260,40 +4339,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211: + case 212: return true; - case 138: - return node.parent.kind === 211; - case 135: - return node.parent.body && node.parent.parent.kind === 211; - case 142: + case 139: + return node.parent.kind === 212; + case 136: + return node.parent.body && node.parent.parent.kind === 212; case 143: - case 140: - return node.body && node.parent.kind === 211; + case 144: + case 141: + return node.body && node.parent.kind === 212; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211: + case 212: if (node.decorators) { return true; } return false; - case 138: - case 135: + case 139: + case 136: if (node.decorators) { return true; } return false; - case 142: + case 143: if (node.body && node.decorators) { return true; } return false; - case 140: - case 143: + case 141: + case 144: if (node.body && node.decorators) { return true; } @@ -4304,10 +4383,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211: + case 212: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140: - case 143: + case 141: + case 144: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4319,92 +4398,92 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 9: - case 161: + case 95: + case 93: + case 91: + case 97: + case 82: + case 10: case 162: case 163: case 164: case 165: case 166: case 167: - case 186: case 168: + case 187: case 169: case 170: - case 183: case 171: - case 174: + case 184: case 172: + case 175: case 173: - case 176: + case 174: case 177: case 178: case 179: - case 182: case 180: - case 10: - case 184: - case 230: - case 231: + case 183: case 181: + case 11: + case 185: + case 231: + case 232: + case 182: return true; - case 132: - while (node.parent.kind === 132) { + case 133: + while (node.parent.kind === 133) { node = node.parent; } - return node.parent.kind === 151; - case 66: - if (node.parent.kind === 151) { + return node.parent.kind === 152; + case 67: + if (node.parent.kind === 152) { return true; } - case 7: case 8: + case 9: var parent_2 = node.parent; switch (parent_2.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 244: - case 242: - case 160: + case 245: + case 243: + case 161: return parent_2.initializer === node; - case 192: case 193: case 194: case 195: - case 201: + case 196: case 202: case 203: - case 238: - case 205: - case 203: + case 204: + case 239: + case 206: + case 204: return parent_2.expression === node; - case 196: + case 197: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || forStatement.condition === node || forStatement.incrementor === node; - case 197: case 198: + case 199: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || forInStatement.expression === node; - case 168: - case 186: - return node === parent_2.expression; + case 169: case 187: return node === parent_2.expression; - case 133: + case 188: return node === parent_2.expression; - case 136: + case 134: + return node === parent_2.expression; + case 137: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4422,7 +4501,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind === 229; + return node.kind === 219 && node.moduleReference.kind === 230; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4431,20 +4510,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind !== 229; + return node.kind === 219 && node.moduleReference.kind !== 230; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219) { + if (node.kind === 220) { return node.moduleSpecifier; } - if (node.kind === 218) { + if (node.kind === 219) { var reference = node.moduleReference; - if (reference.kind === 229) { + if (reference.kind === 230) { return reference.expression; } } - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } } @@ -4452,15 +4531,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135: - return node.questionToken !== undefined; + case 136: + case 141: case 140: - case 139: - return node.questionToken !== undefined; + case 244: case 243: - case 242: + case 139: case 138: - case 137: return node.questionToken !== undefined; } } @@ -4468,9 +4545,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 && + return node.kind === 259 && node.parameters.length > 0 && - node.parameters[0].type.kind === 260; + node.parameters[0].type.kind === 261; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4484,24 +4561,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 267); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265); + return getJSDocTag(node, 266); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 268); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66) { + if (parameter.name && parameter.name.kind === 67) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264) { + if (t.kind === 265) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4520,12 +4597,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 259) { + if (node.type && node.type.kind === 260) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259; + return paramTag.typeExpression.type.kind === 260; } } return node.dotDotDotToken !== undefined; @@ -4534,19 +4611,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 <= kind && kind <= 10; + return 8 <= kind && kind <= 11; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 || kind === 10; + return kind === 9 || kind === 11; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 <= kind && kind <= 13; + return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 || node.kind === 158); + return !!node && (node.kind === 160 || node.kind === 159); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4561,34 +4638,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171: - case 160: - case 211: - case 183: - case 141: - case 214: - case 244: - case 227: - case 210: - case 170: - case 142: - case 220: - case 218: - case 223: + case 172: + case 161: case 212: - case 140: - case 139: + case 184: + case 142: case 215: - case 221: - case 135: - case 242: - case 138: - case 137: + case 245: + case 228: + case 211: + case 171: case 143: - case 243: + case 221: + case 219: + case 224: case 213: - case 134: - case 208: + case 141: + case 140: + case 216: + case 222: + case 136: + case 243: + case 139: + case 138: + case 144: + case 244: + case 214: + case 135: + case 209: return true; } return false; @@ -4596,25 +4673,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200: - case 199: - case 207: - case 194: - case 192: - case 191: - case 197: - case 198: - case 196: - case 193: - case 204: case 201: - case 203: - case 95: - case 206: - case 190: + case 200: + case 208: case 195: + case 193: + case 192: + case 198: + case 199: + case 197: + case 194: + case 205: case 202: - case 224: + case 204: + case 96: + case 207: + case 191: + case 196: + case 203: + case 225: return true; default: return false; @@ -4623,13 +4700,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141: - case 138: - case 140: case 142: - case 143: case 139: - case 146: + case 141: + case 143: + case 144: + case 140: + case 147: return true; default: return false; @@ -4637,11 +4714,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 223 || parent.kind === 227) { + if (parent.kind === 224 || parent.kind === 228) { if (parent.propertyName) { return true; } @@ -4655,54 +4732,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138: - case 137: - case 140: case 139: - case 142: + case 138: + case 141: + case 140: case 143: - case 244: - case 242: - case 163: + case 144: + case 245: + case 243: + case 164: return parent.name === node; - case 132: + case 133: if (parent.right === node) { - while (parent.kind === 132) { + while (parent.kind === 133) { parent = parent.parent; } - return parent.kind === 151; + return parent.kind === 152; } return false; - case 160: - case 223: + case 161: + case 224: return parent.propertyName === node; - case 227: + case 228: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 218 || - node.kind === 220 && !!node.name || - node.kind === 221 || - node.kind === 223 || - node.kind === 227 || - node.kind === 224 && node.expression.kind === 66; + return node.kind === 219 || + node.kind === 221 && !!node.name || + node.kind === 222 || + node.kind === 224 || + node.kind === 228 || + node.kind === 225 && node.expression.kind === 67; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103); + var heritageClause = getHeritageClause(node.heritageClauses, 104); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4771,11 +4848,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 <= token && token <= 131; + return 68 <= token && token <= 132; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 <= token && token <= 6; + return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -4784,19 +4861,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 && + declaration.name.kind === 134 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 && isESSymbolIdentifier(node.expression); + return node.kind === 164 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 || name.kind === 8 || name.kind === 7) { + if (name.kind === 67 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 133) { + if (name.kind === 134) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4811,21 +4888,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 66 && node.text === "Symbol"; + return node.kind === 67 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112: - case 115: - case 71: - case 119: - case 74: - case 79: - case 109: - case 107: - case 108: + case 113: + case 116: + case 72: + case 120: + case 75: + case 80: case 110: + case 108: + case 109: + case 111: return true; } return false; @@ -4833,20 +4910,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135; + return root.kind === 136; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 || n.kind === 245; + return isFunctionLike(n) || n.kind === 216 || n.kind === 246; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67) { + var clone_1 = createSynthesizedNode(67); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -5071,7 +5164,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 && nodeIsPresent(member.body)) { + if (member.kind === 142 && nodeIsPresent(member.body)) { return member; } }); @@ -5083,7 +5176,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; @@ -5098,10 +5191,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142) { + if (accessor.kind === 143) { getAccessor = accessor; } - else if (accessor.kind === 143) { + else if (accessor.kind === 144) { setAccessor = accessor; } else { @@ -5110,7 +5203,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 || member.kind === 143) + if ((member.kind === 143 || member.kind === 144) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5121,10 +5214,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 && !getAccessor) { + if (member.kind === 143 && !getAccessor) { getAccessor = member; } - if (member.kind === 143 && !setAccessor) { + if (member.kind === 144 && !setAccessor) { setAccessor = member; } } @@ -5203,7 +5296,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { writer.write(currentLineText); if (end !== comment.end) { @@ -5230,16 +5323,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110: return 128; - case 109: return 16; - case 108: return 64; - case 107: return 32; - case 112: return 256; - case 79: return 1; - case 119: return 2; - case 71: return 32768; - case 74: return 1024; - case 115: return 512; + case 111: return 128; + case 110: return 16; + case 109: return 64; + case 108: return 32; + case 113: return 256; + case 80: return 1; + case 120: return 2; + case 72: return 32768; + case 75: return 1024; + case 116: return 512; } return 0; } @@ -5247,29 +5340,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163: case 164: - case 166: case 165: - case 230: - case 231: case 167: - case 161: - case 169: + case 166: + case 231: + case 232: + case 168: case 162: - case 183: case 170: - case 66: - case 9: - case 7: - case 8: + case 163: + case 184: + case 171: + case 67: case 10: - case 180: - case 81: - case 90: - case 94: - case 96: - case 92: + case 8: + case 9: + case 11: + case 181: + case 82: + case 91: + case 95: + case 97: + case 93: return true; } } @@ -5277,12 +5370,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 && token <= 65; + return token >= 55 && token <= 66; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 && - node.parent.token === 80 && + return node.kind === 186 && + node.parent.token === 81 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5291,10 +5384,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66) { + if (node.kind === 67) { return true; } - else if (node.kind === 163) { + else if (node.kind === 164) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5302,10 +5395,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 && node.parent.right === node) || - (node.parent.kind === 163 && node.parent.name === node); + return (node.parent.kind === 133 && node.parent.right === node) || + (node.parent.kind === 164 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163) { + return expression.properties.length === 0; + } + if (kind === 162) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -5509,9 +5613,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134) { + if (d && d.kind === 135) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { return current; } } @@ -5523,7 +5627,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269); + var nodeConstructors = new Array(270); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5561,20 +5665,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132: + case 133: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134: + case 135: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135: + case 136: + case 139: case 138: - case 137: - case 242: case 243: - case 208: - case 160: + case 244: + case 209: + case 161: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5583,24 +5687,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149: case 150: - case 144: + case 151: case 145: case 146: + case 147: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: + case 211: + case 172: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5611,160 +5715,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148: + case 149: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147: + case 148: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151: - return visitNode(cbNode, node.exprName); case 152: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 153: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 154: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 155: + return visitNodes(cbNodes, node.elementTypes); case 156: - return visitNodes(cbNodes, node.types); case 157: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 158: + return visitNode(cbNode, node.type); case 159: - return visitNodes(cbNodes, node.elements); - case 161: + case 160: return visitNodes(cbNodes, node.elements); case 162: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 163: + return visitNodes(cbNodes, node.properties); + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164: + case 165: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165: case 166: + case 167: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167: + case 168: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168: + case 169: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169: - return visitNode(cbNode, node.expression); - case 172: + case 170: return visitNode(cbNode, node.expression); case 173: return visitNode(cbNode, node.expression); case 174: return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); case 177: return visitNode(cbNode, node.operand); + case 182: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.operand); + case 179: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186: + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179: + case 180: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182: + case 183: return visitNode(cbNode, node.expression); - case 189: - case 216: + case 190: + case 217: return visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190: + case 191: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209: + case 210: return visitNodes(cbNodes, node.declarations); - case 192: - return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194: + case 195: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 197: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 198: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 199: - case 200: - return visitNode(cbNode, node.label); - case 201: - return visitNode(cbNode, node.expression); - case 202: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 200: + case 201: + return visitNode(cbNode, node.label); + case 202: + return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217: + case 218: return visitNodes(cbNodes, node.clauses); - case 238: + case 239: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239: + case 240: return visitNodes(cbNodes, node.statements); - case 204: + case 205: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205: - return visitNode(cbNode, node.expression); case 206: + return visitNode(cbNode, node.expression); + case 207: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241: + case 242: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 211: - case 183: - 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 212: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5776,125 +5873,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 244: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 245: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219: + case 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220: + case 221: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221: - return visitNode(cbNode, node.name); case 222: - case 226: + return visitNode(cbNode, node.name); + case 223: + case 227: return visitNodes(cbNodes, node.elements); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223: - case 227: + case 224: + case 228: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180: + case 181: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133: + case 134: return visitNode(cbNode, node.expression); - case 240: + case 241: return visitNodes(cbNodes, node.types); - case 185: + case 186: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229: - return visitNode(cbNode, node.expression); - case 228: - return visitNodes(cbNodes, node.decorators); case 230: + return visitNode(cbNode, node.expression); + case 229: + return visitNodes(cbNodes, node.decorators); + case 231: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231: case 232: + case 233: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236: - return visitNode(cbNode, node.expression); case 237: return visitNode(cbNode, node.expression); - case 234: + case 238: + return visitNode(cbNode, node.expression); + case 235: return visitNode(cbNode, node.tagName); - case 246: + case 247: return visitNode(cbNode, node.type); - case 250: - return visitNodes(cbNodes, node.types); case 251: return visitNodes(cbNodes, node.types); - case 249: + case 252: + return visitNodes(cbNodes, node.types); + case 250: return visitNode(cbNode, node.elementType); + case 254: + return visitNode(cbNode, node.type); case 253: return visitNode(cbNode, node.type); - case 252: - return visitNode(cbNode, node.type); - case 254: + case 255: return visitNodes(cbNodes, node.members); - case 256: + case 257: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257: - return visitNode(cbNode, node.type); case 258: + return visitNode(cbNode, node.type); + case 259: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259: - return visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: return visitNode(cbNode, node.type); - case 255: + case 262: + return visitNode(cbNode, node.type); + case 256: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262: + case 263: return visitNodes(cbNodes, node.tags); - case 264: + case 265: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265: - return visitNode(cbNode, node.typeExpression); case 266: return visitNode(cbNode, node.typeExpression); case 267: + return visitNode(cbNode, node.typeExpression); + case 268: return visitNodes(cbNodes, node.typeParameters); } } @@ -5990,9 +6094,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 190: - case 210: - case 135: + case 191: + case 211: + case 136: addJSDocComment(node); } forEachChild(node, visit); @@ -6030,7 +6134,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245, 0); + var sourceFile = createNode(246, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6163,6 +6267,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -6186,20 +6293,23 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 66) { + if (token === 67) { return true; } - if (token === 111 && inYieldContext()) { + if (token === 112 && inYieldContext()) { return false; } - if (token === 116 && inAwaitContext()) { + if (token === 117 && inAwaitContext()) { return false; } - return token > 102; + return token > 103; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } if (diagnosticMessage) { @@ -6233,20 +6343,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token === 22) { + if (token === 23) { return true; } - return token === 15 || token === 1 || scanner.hasPrecedingLineBreak(); + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22) { + if (token === 23) { nextToken(); } return true; } else { - return parseExpected(22); + return parseExpected(23); } } function createNode(kind, pos) { @@ -6288,15 +6398,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66); - if (token !== 66) { + var node = createNode(67); + if (token !== 67) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6306,14 +6416,14 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 || - token === 7; + token === 9 || + token === 8; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 || token === 7) { + if (token === 9 || token === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token === 18) { + if (allowComputedPropertyNames && token === 19) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -6325,30 +6435,30 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 8 || token === 7 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(133); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(134); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71) { - return nextToken() === 78; + if (token === 72) { + return nextToken() === 79; } - if (token === 79) { + if (token === 80) { nextToken(); - if (token === 74) { + if (token === 75) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 && token !== 14 && canFollowModifier(); + return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 74) { + if (token === 75) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -6358,14 +6468,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 - || token === 14 - || token === 36 + return token === 19 + || token === 15 + || token === 37 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 || token === 84; + return token === 71 || token === 85; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6376,21 +6486,21 @@ var ts; case 0: case 1: case 3: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 68 || token === 74; + return token === 69 || token === 75; case 4: return isStartOfTypeMember(); case 5: - return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: - return token === 18 || isLiteralPropertyName(); + return token === 19 || isLiteralPropertyName(); case 12: - return token === 18 || token === 36 || isLiteralPropertyName(); + return token === 19 || token === 37 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: - if (token === 14) { + if (token === 15) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -6402,23 +6512,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token === 23 || token === 21 || isIdentifierOrPattern(); + return token === 24 || token === 22 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token === 23 || token === 21 || isStartOfExpression(); + return token === 24 || token === 22 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token === 23 || isStartOfType(); + return token === 24 || isStartOfType(); case 20: return isHeritageClause(); case 21: return isIdentifierOrKeyword(); case 13: - return isIdentifierOrKeyword() || token === 14; + return isIdentifierOrKeyword() || token === 15; case 14: return true; case 22: @@ -6431,10 +6541,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14); - if (nextToken() === 15) { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { var next = nextToken(); - return next === 23 || next === 14 || next === 80 || next === 103; + return next === 24 || next === 15 || next === 81 || next === 104; } return true; } @@ -6447,8 +6557,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6470,39 +6580,39 @@ var ts; case 12: case 9: case 21: - return token === 15; + return token === 16; case 3: - return token === 15 || token === 68 || token === 74; + return token === 16 || token === 69 || token === 75; case 7: - return token === 14 || token === 80 || token === 103; + return token === 15 || token === 81 || token === 104; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; + return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; case 11: - return token === 17 || token === 22; + return token === 18 || token === 23; case 15: case 19: case 10: - return token === 19; + return token === 20; case 16: - return token === 17 || token === 19; + return token === 18 || token === 20; case 18: - return token === 26 || token === 16; + return token === 27 || token === 17; case 20: - return token === 14 || token === 15; + return token === 15 || token === 16; case 13: - return token === 26 || token === 37; + return token === 27 || token === 38; case 14: - return token === 24 && lookAhead(nextTokenIsSlash); + return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 17 || token === 52 || token === 15; + return token === 18 || token === 53 || token === 16; case 23: - return token === 26 || token === 15; + return token === 27 || token === 16; case 25: - return token === 19 || token === 15; + return token === 20 || token === 16; case 24: - return token === 15; + return token === 16; } } function isVariableDeclaratorListTerminator() { @@ -6512,7 +6622,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6617,17 +6727,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141: - case 146: case 142: + case 147: case 143: - case 138: - case 188: + case 144: + case 139: + case 189: return true; - case 140: + case 141: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 && - methodDeclaration.name.originalKeywordKind === 118; + var nameIsConstructor = methodDeclaration.name.kind === 67 && + methodDeclaration.name.originalKeywordKind === 119; return !nameIsConstructor; } } @@ -6636,8 +6746,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6646,65 +6756,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210: + case 211: + case 191: case 190: - case 189: + case 194: case 193: - case 192: - case 205: + case 206: + case 202: + case 204: case 201: - case 203: case 200: + case 198: case 199: case 197: - case 198: case 196: - case 195: - case 202: - case 191: - case 206: - case 204: - case 194: + case 203: + case 192: case 207: + case 205: + case 195: + case 208: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 215: - case 211: + case 216: case 212: - case 214: case 213: + case 215: + case 214: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244; + return node.kind === 245; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145: - case 139: case 146: - case 137: - case 144: + case 140: + case 147: + case 138: + case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208) { + if (node.kind !== 209) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135) { + if (node.kind !== 136) { return false; } var parameter = node; @@ -6759,15 +6869,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23)) { + if (parseOptional(24)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(23); - if (considerSemicolonAsDelimeter && token === 22 && !scanner.hasPrecedingLineBreak()) { + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -6803,8 +6913,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20)) { - var node = createNode(132, entity.pos); + while (parseOptional(21)) { + var node = createNode(133, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6815,34 +6925,34 @@ var ts; if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180); + var template = createNode(181); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187); + var span = createNode(188); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15) { + if (token === 16) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13, false, ts.Diagnostics._0_expected, ts.tokenToString(15)); + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); } span.literal = literal; return finishNode(span); @@ -6860,7 +6970,7 @@ var ts; var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 7 + if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536; @@ -6869,30 +6979,30 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147, typeName.pos); + var node_1 = createNode(148, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148, typeName.pos); + var node = createNode(149, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151); - parseExpected(98); + var node = createNode(152); + parseExpected(99); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134); + var node = createNode(135); node.name = parseIdentifier(); - if (parseOptional(80)) { + if (parseOptional(81)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6903,20 +7013,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24) { - return parseBracketedList(17, parseTypeParameter, 24, 26); + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); } } function parseParameterType() { - if (parseOptional(52)) { - return token === 8 + if (parseOptional(53)) { + return token === 9 ? parseLiteralNode(true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6925,15 +7035,15 @@ var ts; } } function parseParameter() { - var node = createNode(135); + var node = createNode(136); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(51); + node.questionToken = parseOptionalToken(52); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6945,7 +7055,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33; + var returnTokenRequired = returnToken === 34; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -6957,7 +7067,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6965,7 +7075,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17) && requireCompleteParameterList) { + if (!parseExpected(18) && requireCompleteParameterList) { return undefined; } return result; @@ -6973,29 +7083,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(23)) { + if (parseOptional(24)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145) { - parseExpected(89); + if (kind === 146) { + parseExpected(90); } - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18) { + if (token !== 19) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token === 21 || token === 19) { + if (token === 22 || token === 20) { return true; } if (ts.isModifier(token)) { @@ -7010,20 +7120,20 @@ var ts; else { nextToken(); } - if (token === 52 || token === 23) { + if (token === 53 || token === 24) { return true; } - if (token !== 51) { + if (token !== 52) { return false; } nextToken(); - return token === 52 || token === 23 || token === 19; + return token === 53 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146, fullStart); + var node = createNode(147, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -7031,17 +7141,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (token === 16 || token === 24) { - var method = createNode(139, fullStart); + var questionToken = parseOptionalToken(52); + if (token === 17 || token === 25) { + var method = createNode(140, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(52, false, false, false, method); + fillSignature(53, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137, fullStart); + var property = createNode(138, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7051,9 +7161,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16: - case 24: - case 18: + case 17: + case 25: + case 19: return true; default: if (ts.isModifier(token)) { @@ -7073,27 +7183,27 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 || - token === 24 || - token === 51 || + return token === 17 || + token === 25 || token === 52 || + token === 53 || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16: - case 24: - return parseSignatureMember(144); - case 18: + case 17: + case 25: + return parseSignatureMember(145); + case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 89: + case 90: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145); + return parseSignatureMember(146); } + case 9: case 8: - case 7: return parsePropertyOrMethodSignature(); default: if (ts.isModifier(token)) { @@ -7117,18 +7227,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 || token === 24; + return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(152); + var node = createNode(153); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14)) { + if (parseExpected(15)) { members = parseList(4, parseTypeMember); - parseExpected(15); + parseExpected(16); } else { members = createMissingList(); @@ -7136,47 +7246,47 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154); - node.elementTypes = parseBracketedList(19, parseType, 18, 19); + var node = createNode(155); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157); - parseExpected(16); - node.type = parseType(); + var node = createNode(158); parseExpected(17); + node.type = parseType(); + parseExpected(18); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150) { - parseExpected(89); + if (kind === 151) { + parseExpected(90); } - fillSignature(33, false, false, false, node); + fillSignature(34, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 ? undefined : node; + return token === 21 ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: + case 126: + case 118: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100: + case 101: return parseTokenNode(); - case 98: + case 99: return parseTypeQuery(); - case 14: + case 15: return parseTypeLiteral(); - case 18: + case 19: return parseTupleType(); - case 16: + case 17: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -7184,19 +7294,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 98: - case 14: - case 18: - case 24: - case 89: + case 126: + case 118: + case 129: + case 101: + case 99: + case 15: + case 19: + case 25: + case 90: return true; - case 16: + case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -7204,13 +7314,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 || isStartOfParameter() || isStartOfType(); + return token === 18 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { - parseExpected(19); - var node = createNode(153, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(154, type.pos); node.elementType = type; type = finishNode(node); } @@ -7232,32 +7342,32 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); } function isStartOfFunctionType() { - if (token === 24) { + if (token === 25) { return true; } - return token === 16 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 || token === 21) { + if (token === 18 || token === 22) { return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 || token === 23 || - token === 51 || token === 54 || + if (token === 53 || token === 24 || + token === 52 || token === 55 || isIdentifier() || ts.isModifier(token)) { return true; } - if (token === 17) { + if (token === 18) { nextToken(); - if (token === 33) { + if (token === 34) { return true; } } @@ -7269,36 +7379,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149); - } - if (token === 89) { return parseFunctionOrConstructorType(150); } + if (token === 90) { + return parseFunctionOrConstructorType(151); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52) ? parseType() : undefined; + return parseOptional(53) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 7: + case 95: + case 93: + case 91: + case 97: + case 82: case 8: - case 10: + case 9: case 11: - case 16: - case 18: - case 14: - case 84: - case 70: - case 89: - case 37: - case 58: - case 66: + case 12: + case 17: + case 19: + case 15: + case 85: + case 71: + case 90: + case 38: + case 59: + case 67: return true; default: return isIdentifier(); @@ -7309,18 +7419,18 @@ var ts; return true; } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 75: - case 98: - case 100: - case 39: + case 76: + case 99: + case 101: case 40: - case 24: - case 116: - case 111: + case 41: + case 25: + case 117: + case 112: return true; default: if (isBinaryOperator()) { @@ -7330,10 +7440,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && - token !== 84 && - token !== 70 && - token !== 53 && + return token !== 15 && + token !== 85 && + token !== 71 && + token !== 54 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7349,7 +7459,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23))) { + while ((operatorToken = parseOptionalToken(24))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -7358,12 +7468,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { + if (token !== 55) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(54); + parseExpected(55); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7384,7 +7494,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 66 && token === 33) { + if (expr.kind === 67 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7393,7 +7503,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7406,11 +7516,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36); + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7419,15 +7529,15 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171, identifier.pos); - var parameter = createNode(135, identifier.pos); + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172, identifier.pos); + var parameter = createNode(136, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } @@ -7444,78 +7554,78 @@ var ts; } var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 || lastToken === 14) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24 || token === 115) { + if (token === 17 || token === 25 || token === 116) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33) { + if (token === 34) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115) { + if (token === 116) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token !== 16 && token !== 24) { + if (token !== 17 && token !== 25) { return 0; } } var first = token; var second = nextToken(); - if (first === 16) { - if (second === 17) { + if (first === 17) { + if (second === 18) { var third = nextToken(); switch (third) { - case 33: - case 52: - case 14: + case 34: + case 53: + case 15: return 1; default: return 0; } } - if (second === 18 || second === 14) { + if (second === 19 || second === 15) { return 2; } - if (second === 21) { + if (second === 22) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 52) { + if (nextToken() === 53) { return 1; } return 2; } else { - ts.Debug.assert(first === 24); + ts.Debug.assert(first === 25); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80) { + if (third === 81) { var fourth = nextToken(); switch (fourth) { - case 54: - case 26: + case 55: + case 27: return false; default: return true; } } - else if (third === 23) { + else if (third === 24) { return true; } return false; @@ -7532,25 +7642,25 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171); + var node = createNode(172); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(52, false, isAsync, !allowAmbiguity, node); + fillSignature(53, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 33 && token !== 14) { + if (!allowAmbiguity && token !== 34 && token !== 15) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14) { + if (token === 15) { return parseFunctionBlock(false, isAsync, false); } - if (token !== 22 && - token !== 84 && - token !== 70 && + if (token !== 23 && + token !== 85 && + token !== 71 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7560,15 +7670,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(51); + var questionToken = parseOptionalToken(52); if (!questionToken) { return leftOperand; } - var node = createNode(179, leftOperand.pos); + var node = createNode(180, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); + node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7577,7 +7687,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 || t === 131; + return t === 88 || t === 132; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7586,10 +7696,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 && inDisallowInContext()) { + if (token === 88 && inDisallowInContext()) { break; } - if (token === 113) { + if (token === 114) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7605,90 +7715,90 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87) { + if (inDisallowInContext() && token === 88) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50: + case 51: return 1; - case 49: + case 50: return 2; - case 45: - return 3; case 46: + return 3; + case 47: return 4; - case 44: + case 45: return 5; - case 29: case 30: case 31: case 32: + case 33: return 6; - case 24: - case 26: + case 25: case 27: case 28: + case 29: + case 89: case 88: - case 87: - case 113: + case 114: return 7; - case 41: case 42: case 43: + case 44: return 8; - case 34: case 35: - return 9; case 36: + return 9; case 37: case 38: + case 39: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178, left.pos); + var node = createNode(179, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186, left.pos); + var node = createNode(187, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176); + var node = createNode(177); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(174); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function isAwaitExpression() { - if (token === 116) { + if (token === 117) { if (inAwaitContext()) { return true; } @@ -7697,7 +7807,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7707,25 +7817,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return parsePrefixUnaryExpression(); - case 75: + case 76: return parseDeleteExpression(); - case 98: + case 99: return parseTypeOfExpression(); - case 100: + case 101: return parseVoidExpression(); - case 24: + case 25: if (sourceFile.languageVariant !== 1) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(true); } default: return parsePostfixExpressionOrHigher(); @@ -7734,8 +7844,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177, expression.pos); + if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7744,7 +7854,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7755,44 +7865,44 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 || token === 20) { + if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(163, expression.pos); + var node = createNode(164, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232) { - var node = createNode(230, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233) { + var node = createNode(231, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231); + ts.Debug.assert(opening.kind === 232); return opening; } } function parseJsxText() { - var node = createNode(233, scanner.getStartPos()); + var node = createNode(234, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233: + case 234: return parseJsxText(); - case 14: - return parseJsxExpression(); - case 24: - return parseJsxElementOrSelfClosingElement(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -7801,7 +7911,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7814,19 +7924,26 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24); + parseExpected(25); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (parseOptional(26)) { - node = createNode(232, fullStart); + if (token === 27) { + node = createNode(233, fullStart); + scanJsxText(); } else { - parseExpected(37); - parseExpected(26); - node = createNode(231, fullStart); + parseExpected(38); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(232, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7835,95 +7952,107 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20)) { + while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(132, elementName.pos); + var node = createNode(133, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237); - parseExpected(14); - if (token !== 15) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238); + parseExpected(15); + if (token !== 16) { node.expression = parseExpression(); } - parseExpected(15); + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14) { + if (token === 15) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235); + var node = createNode(236); node.name = parseIdentifierName(); - if (parseOptional(54)) { + if (parseOptional(55)) { switch (token) { - case 8: + case 9: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236); - parseExpected(14); - parseExpected(21); - node.expression = parseExpression(); + var node = createNode(237); parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234); - parseExpected(25); - node.tagName = parseJsxElementName(); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235); parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168); - parseExpected(24); + var node = createNode(169); + parseExpected(25); node.type = parseType(); - parseExpected(26); + parseExpected(27); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20); + var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(163, expression.pos); + var propertyAccess = createNode(164, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(164, expression.pos); + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(165, expression.pos); indexedAccess.expression = expression; - if (token !== 19) { + if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 || indexedAccess.argumentExpression.kind === 7) { + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19); + parseExpected(20); expression = finishNode(indexedAccess); continue; } - if (token === 10 || token === 11) { - var tagExpression = createNode(167, expression.pos); + if (token === 11 || token === 12) { + var tagExpression = createNode(168, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 + tagExpression.template = token === 11 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -7935,20 +8064,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24) { + if (token === 25) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(165, expression.pos); + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16) { - var callExpr = createNode(165, expression.pos); + else if (token === 17) { + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7958,17 +8087,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24)) { + if (!parseOptional(25)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(26)) { + if (!parseExpected(27)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7977,108 +8106,108 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16: - case 20: case 17: - case 19: + case 21: + case 18: + case 20: + case 53: + case 23: case 52: - case 22: - case 51: - case 29: - case 31: case 30: case 32: - case 49: + case 31: + case 33: case 50: - case 46: - case 44: + case 51: + case 47: case 45: - case 15: + case 46: + case 16: case 1: return true; - case 23: - case 14: + case 24: + case 15: default: return false; } } function parsePrimaryExpression() { switch (token) { - case 7: case 8: - case 10: + case 9: + case 11: return parseLiteralNode(); - case 94: - case 92: - case 90: - case 96: - case 81: + case 95: + case 93: + case 91: + case 97: + case 82: return parseTokenNode(); - case 16: + case 17: return parseParenthesizedExpression(); - case 18: + case 19: return parseArrayLiteralExpression(); - case 14: + case 15: return parseObjectLiteralExpression(); - case 115: + case 116: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 70: + case 71: return parseClassExpression(); - case 84: + case 85: return parseFunctionExpression(); - case 89: + case 90: return parseNewExpression(); - case 37: - case 58: - if (reScanSlashToken() === 9) { + case 38: + case 59: + if (reScanSlashToken() === 10) { return parseLiteralNode(); } break; - case 11: + case 12: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(170); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182); - parseExpected(21); + var node = createNode(183); + parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(184) : + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(185) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161); - parseExpected(18); + var node = createNode(162); + parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(19); + parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120)) { - return parseAccessorDeclaration(142, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(126)) { + if (parseContextualModifier(121)) { return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } + else if (parseContextualModifier(127)) { + return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -8089,37 +8218,37 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243, fullStart); + if ((token === 24 || token === 16) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242, fullStart); + var propertyAssignment = createNode(243, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52); + parseExpected(53); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162); - parseExpected(14); + var node = createNode(163); + parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(15); + parseExpected(16); return finishNode(node); } function parseFunctionExpression() { @@ -8127,10 +8256,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170); + var node = createNode(171); setModifiers(node, parseModifiers()); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); node.name = @@ -8138,7 +8267,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8149,20 +8278,20 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166); - parseExpected(89); + var node = createNode(167); + parseExpected(90); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16) { + if (node.typeArguments || token === 17) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189); - if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -8187,47 +8316,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(193); - parseExpected(85); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(194); + parseExpected(86); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194); - parseExpected(76); + var node = createNode(195); + parseExpected(77); node.statement = parseStatement(); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + parseExpected(102); parseExpected(17); - parseOptional(22); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(196); + parseExpected(102); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83); - parseExpected(16); + parseExpected(84); + parseExpected(17); var initializer = undefined; - if (token !== 22) { - if (token === 99 || token === 105 || token === 71) { + if (token !== 23) { + if (token === 100 || token === 106 || token === 72) { initializer = parseVariableDeclarationList(true); } else { @@ -8235,32 +8364,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(87)) { - var forInStatement = createNode(197, pos); + if (parseOptional(88)) { + var forInStatement = createNode(198, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131)) { - var forOfStatement = createNode(198, pos); + else if (parseOptional(132)) { + var forOfStatement = createNode(199, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196, pos); + var forStatement = createNode(197, pos); forStatement.initializer = initializer; - parseExpected(22); - if (token !== 22 && token !== 17) { + parseExpected(23); + if (token !== 23 && token !== 18) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22); - if (token !== 17) { + parseExpected(23); + if (token !== 18) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -8268,7 +8397,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 ? 67 : 72); + parseExpected(kind === 201 ? 68 : 73); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8276,8 +8405,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201); - parseExpected(91); + var node = createNode(202); + parseExpected(92); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8285,99 +8414,99 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202); - parseExpected(102); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(203); + parseExpected(103); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238); - parseExpected(68); + var node = createNode(239); + parseExpected(69); node.expression = allowInAnd(parseExpression); - parseExpected(52); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239); - parseExpected(74); - parseExpected(52); + var node = createNode(240); + parseExpected(75); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 ? parseCaseClause() : parseDefaultClause(); + return token === 69 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203); - parseExpected(93); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(94); parseExpected(17); - var caseBlock = createNode(217, scanner.getStartPos()); - parseExpected(14); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(218, scanner.getStartPos()); parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(205); - parseExpected(95); + var node = createNode(206); + parseExpected(96); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(206); - parseExpected(97); + var node = createNode(207); + parseExpected(98); node.tryBlock = parseBlock(false); - node.catchClause = token === 69 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 82) { - parseExpected(82); + node.catchClause = token === 70 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 83) { + parseExpected(83); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241); - parseExpected(69); - if (parseExpected(16)) { + var result = createNode(242); + parseExpected(70); + if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17); + parseExpected(18); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207); - parseExpected(73); + var node = createNode(208); + parseExpected(74); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 && parseOptional(52)) { - var labeledStatement = createNode(204, fullStart); + if (expression.kind === 67 && parseOptional(53)) { + var labeledStatement = createNode(205, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192, fullStart); + var expressionStatement = createNode(193, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66; + return token >= 67; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -8385,51 +8514,51 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 && !scanner.hasPrecedingLineBreak(); + return token === 85 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99: - case 105: + case 100: + case 106: + case 72: + case 85: case 71: - case 84: - case 70: - case 78: + case 79: return true; - case 104: - case 129: + case 105: + case 130: return nextTokenIsIdentifierOnSameLine(); - case 122: case 123: + case 124: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 119: + case 116: + case 120: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86: + case 87: nextToken(); - return token === 8 || token === 36 || - token === 14 || isIdentifierOrKeyword(); - case 79: + return token === 9 || token === 37 || + token === 15 || isIdentifierOrKeyword(); + case 80: nextToken(); - if (token === 54 || token === 36 || - token === 14 || token === 74) { + if (token === 55 || token === 37 || + token === 15 || token === 75) { return true; } continue; - case 109: - case 107: - case 108: case 110: - case 112: + case 108: + case 109: + case 111: + case 113: nextToken(); continue; default: @@ -8442,44 +8571,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53: - case 22: - case 14: - case 99: - case 105: - case 84: - case 70: - case 78: + case 54: + case 23: + case 15: + case 100: + case 106: case 85: - case 76: - case 101: - case 83: - case 72: - case 67: - case 91: - case 102: - case 93: - case 95: - case 97: - case 73: - case 69: - case 82: - return true; case 71: case 79: case 86: - return isStartOfDeclaration(); - case 115: - case 119: - case 104: - case 122: - case 123: - case 129: + case 77: + case 102: + case 84: + case 73: + case 68: + case 92: + case 103: + case 94: + case 96: + case 98: + case 74: + case 70: + case 83: + return true; + case 72: + case 80: + case 87: + return isStartOfDeclaration(); + case 116: + case 120: + case 105: + case 123: + case 124: + case 130: return true; - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8487,71 +8616,71 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 || token === 18; + return isIdentifier() || token === 15 || token === 19; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token) { - case 22: + case 23: return parseEmptyStatement(); - case 14: + case 15: return parseBlock(false); - case 99: + case 100: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105: + case 106: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 84: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - return parseIfStatement(); - case 76: - return parseDoStatement(); - case 101: - return parseWhileStatement(); - case 83: - return parseForOrForInOrForOfStatement(); - case 72: - return parseBreakOrContinueStatement(199); - case 67: - return parseBreakOrContinueStatement(200); - case 91: - return parseReturnStatement(); - case 102: - return parseWithStatement(); - case 93: - return parseSwitchStatement(); - case 95: - return parseThrowStatement(); - case 97: - case 69: - case 82: - return parseTryStatement(); - case 73: - return parseDebuggerStatement(); - case 53: - return parseDeclaration(); - case 115: - case 104: - case 129: - case 122: - case 123: - case 119: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 71: - case 78: - case 79: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 86: - case 107: + return parseIfStatement(); + case 77: + return parseDoStatement(); + case 102: + return parseWhileStatement(); + case 84: + return parseForOrForInOrForOfStatement(); + case 73: + return parseBreakOrContinueStatement(200); + case 68: + return parseBreakOrContinueStatement(201); + case 92: + return parseReturnStatement(); + case 103: + return parseWithStatement(); + case 94: + return parseSwitchStatement(); + case 96: + return parseThrowStatement(); + case 98: + case 70: + case 83: + return parseTryStatement(); + case 74: + return parseDebuggerStatement(); + case 54: + return parseDeclaration(); + case 116: + case 105: + case 130: + case 123: + case 124: + case 120: + case 72: + case 79: + case 80: + case 87: case 108: case 109: - case 112: case 110: + case 113: + case 111: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8564,33 +8693,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99: - case 105: - case 71: + case 100: + case 106: + case 72: return parseVariableStatement(fullStart, decorators, modifiers); - case 84: + case 85: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70: + case 71: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104: + case 105: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129: + case 130: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122: - case 123: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 79: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 123: + case 124: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 87: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 80: nextToken(); - return token === 74 || token === 54 ? + return token === 75 || token === 55 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8600,34 +8729,34 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 && canParseSemicolon()) { + if (token !== 15 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token === 23) { - return createNode(184); + if (token === 24) { + return createNode(185); } - var node = createNode(160); - node.dotDotDotToken = parseOptionalToken(21); + var node = createNode(161); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160); + var node = createNode(161); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52) { + if (tokenIsIdentifier && token !== 53) { node.name = propertyName; } else { - parseExpected(52); + parseExpected(53); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8635,33 +8764,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158); - parseExpected(14); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(159); parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159); - parseExpected(18); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(160); parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 || token === 18 || isIdentifier(); + return token === 15 || token === 19 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18) { + if (token === 19) { return parseArrayBindingPattern(); } - if (token === 14) { + if (token === 15) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208); + var node = createNode(209); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8670,21 +8799,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209); + var node = createNode(210); switch (token) { - case 99: + case 100: break; - case 105: + case 106: node.flags |= 16384; break; - case 71: + case 72: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8696,10 +8825,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17; + return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190, fullStart); + var node = createNode(191, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8707,29 +8836,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210, fullStart); + var node = createNode(211, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141, pos); + var node = createNode(142, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118); - fillSignature(52, false, false, false, node); + parseExpected(119); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140, fullStart); + var method = createNode(141, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8737,12 +8866,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(52, isGenerator, isAsync, false, method); + fillSignature(53, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138, fullStart); + var property = createNode(139, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8755,10 +8884,10 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -8773,16 +8902,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return true; default: return false; @@ -8790,7 +8919,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8800,26 +8929,26 @@ var ts; } nextToken(); } - if (token === 36) { + if (token === 37) { return true; } if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 18) { + if (token === 19) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { + if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { return true; } switch (token) { - case 16: - case 24: + case 17: + case 25: + case 53: + case 55: case 52: - case 54: - case 51: return true; default: return canParseSemicolon(); @@ -8831,14 +8960,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53)) { + if (!parseOptional(54)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136, decoratorStart); + var decorator = createNode(137, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8872,7 +9001,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115) { + if (token === 116) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8886,8 +9015,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22) { - var result = createNode(188); + if (token === 23) { + var result = createNode(189); nextToken(); return finishNode(result); } @@ -8898,42 +9027,42 @@ var ts; if (accessor) { return accessor; } - if (token === 118) { + if (token === 119) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || + token === 9 || token === 8 || - token === 7 || - token === 36 || - token === 18) { + token === 37 || + token === 19) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_7 = createMissingNode(66, true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70); + parseExpected(71); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseClassMembers(); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8952,8 +9081,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 || token === 103) { - var node = createNode(240); + if (token === 81 || token === 104) { + var node = createNode(241); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8962,24 +9091,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185); + var node = createNode(186); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function isHeritageClause() { - return token === 80 || token === 103; + return token === 81 || token === 104; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104); + parseExpected(105); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8987,32 +9116,32 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129); + parseExpected(130); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54); + parseExpected(55); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(245, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78); + parseExpected(79); node.name = parseIdentifier(); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -9020,10 +9149,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216, scanner.getStartPos()); - if (parseExpected(14)) { + var node = createNode(217, scanner.getStartPos()); + if (parseExpected(15)) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -9031,18 +9160,18 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20) + node.body = parseOptional(21) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9051,57 +9180,57 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123)) { + if (parseOptional(124)) { flags |= 131072; } else { - parseExpected(122); - if (token === 8) { + parseExpected(123); + if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 && + return token === 125 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16; + return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 37; + return nextToken() === 38; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 || - token === 130; + return token === 24 || + token === 131; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86); + parseExpected(87); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 130) { - var importEqualsDeclaration = createNode(218, fullStart); + if (token !== 24 && token !== 131) { + var importEqualsDeclaration = createNode(219, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54); + parseExpected(55); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(219, fullStart); + var importDeclaration = createNode(220, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 36 || - token === 14) { + token === 37 || + token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130); + parseExpected(131); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -9114,13 +9243,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220, fullStart); + var importClause = createNode(221, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(23)) { - importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); } return finishNode(importClause); } @@ -9130,37 +9259,37 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(229); - parseExpected(124); - parseExpected(16); - node.expression = parseModuleSpecifier(); + var node = createNode(230); + parseExpected(125); parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); return finishNode(node); } function parseModuleSpecifier() { var result = parseExpression(); - if (result.kind === 8) { + if (result.kind === 9) { internIdentifier(result.text); } return result; } function parseNamespaceImport() { - var namespaceImport = createNode(221); - parseExpected(36); - parseExpected(113); + var namespaceImport = createNode(222); + parseExpected(37); + parseExpected(114); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227); + return parseImportOrExportSpecifier(228); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223); + return parseImportOrExportSpecifier(224); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9168,9 +9297,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113) { + if (token === 114) { node.propertyName = identifierName; - parseExpected(113); + parseExpected(114); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9179,23 +9308,23 @@ var ts; else { node.name = identifierName; } - if (kind === 223 && checkIdentifierIsKeyword) { + if (kind === 224 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36)) { - parseExpected(130); + if (parseOptional(37)) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226); - if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { - parseExpected(130); + node.exportClause = parseNamedImportsOrExports(227); + if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9203,14 +9332,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54)) { + if (parseOptional(55)) { node.isExportEquals = true; } else { - parseExpected(74); + parseExpected(75); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9273,10 +9402,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 218 && node.moduleReference.kind === 229 - || node.kind === 219 - || node.kind === 224 + || node.kind === 219 && node.moduleReference.kind === 230 + || node.kind === 220 || node.kind === 225 + || node.kind === 226 ? node : undefined; }); @@ -9285,16 +9414,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36: - case 51: - case 16: - case 18: - case 47: - case 14: - case 84: - case 21: - case 89: - case 94: + case 37: + case 52: + case 17: + case 19: + case 48: + case 15: + case 85: + case 22: + case 90: + case 95: return true; } return isIdentifierOrKeyword(); @@ -9311,23 +9440,23 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(246); - parseExpected(14); - result.type = parseJSDocTopLevelType(); + var result = createNode(247); parseExpected(15); + result.type = parseJSDocTopLevelType(); + parseExpected(16); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45) { - var unionType = createNode(250, type.pos); + if (token === 46) { + var unionType = createNode(251, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54) { - var optionalType = createNode(257, type.pos); + if (token === 55) { + var optionalType = createNode(258, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9337,21 +9466,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18) { - var arrayType = createNode(249, type.pos); + if (token === 19) { + var arrayType = createNode(250, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19); + parseExpected(20); type = finishNode(arrayType); } - else if (token === 51) { - var nullableType = createNode(252, type.pos); + else if (token === 52) { + var nullableType = createNode(253, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47) { - var nonNullableType = createNode(253, type.pos); + else if (token === 48) { + var nonNullableType = createNode(254, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9364,85 +9493,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36: + case 37: return parseJSDocAllType(); - case 51: + case 52: return parseJSDocUnknownOrNullableType(); - case 16: + case 17: return parseJSDocUnionType(); - case 18: + case 19: return parseJSDocTupleType(); - case 47: + case 48: return parseJSDocNonNullableType(); - case 14: + case 15: return parseJSDocRecordType(); - case 84: + case 85: return parseJSDocFunctionType(); - case 21: + case 22: return parseJSDocVariadicType(); - case 89: + case 90: return parseJSDocConstructorType(); - case 94: + case 95: return parseJSDocThisType(); - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: + case 126: + case 118: + case 129: + case 101: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261); + var result = createNode(262); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260); + var result = createNode(261); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258); + var result = createNode(259); nextToken(); - parseExpected(16); + parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17); - if (token === 52) { + parseExpected(18); + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135); + var parameter = createNode(136); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257, type.pos); + var result = createNode(258, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256); + var result = createNode(257); result.name = parseSimplePropertyName(); - while (parseOptional(20)) { - if (token === 24) { + while (parseOptional(21)) { + if (token === 25) { result.typeArguments = parseTypeArguments(); break; } @@ -9457,7 +9586,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9468,40 +9597,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132, left.pos); + var result = createNode(133, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254); + var result = createNode(255); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15); + parseExpected(16); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255); + var result = createNode(256); result.name = parseSimplePropertyName(); - if (token === 52) { + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253); + var result = createNode(254); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251); + var result = createNode(252); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19); + parseExpected(20); return finishNode(result); } function checkForTrailingComma(list) { @@ -9511,10 +9640,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250); + var result = createNode(251); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17); + parseExpected(18); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -9522,31 +9651,31 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45)) { + while (parseOptional(46)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247); + var result = createNode(248); nextToken(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token === 23 || - token === 15 || - token === 17 || - token === 26 || - token === 54 || - token === 45) { - var result = createNode(248, pos); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 55 || + token === 46) { + var result = createNode(249, pos); return finishNode(result); } else { - var result = createNode(252, pos); + var result = createNode(253, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9617,7 +9746,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262, start); + var result = createNode(263, start); result.tags = tags; return finishNode(result, end); } @@ -9628,7 +9757,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(53, pos - 1); + var atToken = createNode(54, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9654,7 +9783,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9706,7 +9835,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264, atToken.pos); + var result = createNode(265, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9716,16 +9845,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(265, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -9735,10 +9854,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -9749,7 +9878,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134, name_8.pos); + var typeParameter = createNode(135, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9760,7 +9889,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9781,7 +9910,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66, startPos); + var result = createNode(67, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9825,7 +9954,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9855,9 +9984,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { + case 9: case 8: - case 7: - case 66: + case 67: return true; } return false; @@ -10113,17 +10242,18 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -10140,7 +10270,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -10148,16 +10279,17 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(4194304, "symbol"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); - var nullType = createIntrinsicType(64 | 1048576, "null"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -10201,6 +10333,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10222,7 +10355,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10235,6 +10368,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10376,10 +10510,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245); + return ts.getAncestor(node, 246); } function isGlobalSourceFile(node) { - return node.kind === 245 && !ts.isExternalModule(node); + return node.kind === 246 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10402,7 +10536,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -10427,16 +10561,16 @@ var ts; } } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) break; - case 215: + case 216: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 || - (location.kind === 215 && location.name.kind === 8)) { + if (location.kind === 246 || + (location.kind === 216 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 227)) { + ts.getDeclarationOfKind(moduleExports[name], 228)) { break; } result = moduleExports["default"]; @@ -10450,13 +10584,13 @@ var ts; break loop; } break; - case 214: + case 215: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 139: case 138: - case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10466,9 +10600,9 @@ var ts; } } break; - case 211: - case 183: case 212: + case 184: + case 213: 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); @@ -10476,7 +10610,7 @@ var ts; } break loop; } - if (location.kind === 183 && meaning & 32) { + if (location.kind === 184 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10484,28 +10618,28 @@ var ts; } } break; - case 133: + case 134: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213) { 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 140: - case 139: case 141: + case 140: case 142: case 143: - case 210: - case 171: + case 144: + case 211: + case 172: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10518,8 +10652,8 @@ var ts; } } break; - case 136: - if (location.parent && location.parent.kind === 135) { + case 137: + if (location.parent && location.parent.kind === 136) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10545,7 +10679,7 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2) { + if (meaning & 2 && result.flags & 2) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -10557,14 +10691,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, 208); + var variableDeclaration = ts.getAncestor(declaration, 209); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 || - variableDeclaration.parent.parent.kind === 196) { + if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 197) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 197) { + else if (variableDeclaration.parent.parent.kind === 199 || + variableDeclaration.parent.parent.kind === 198) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -10586,10 +10720,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } - while (node && node.kind !== 219) { + while (node && node.kind !== 220) { node = node.parent; } return node; @@ -10599,7 +10733,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229) { + if (node.moduleReference.kind === 230) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10688,17 +10822,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218: + case 219: return getTargetOfImportEqualsDeclaration(node); - case 220: - return getTargetOfImportClause(node); case 221: + return getTargetOfImportClause(node); + case 222: return getTargetOfNamespaceImport(node); - case 223: - return getTargetOfImportSpecifier(node); - case 227: - return getTargetOfExportSpecifier(node); case 224: + return getTargetOfImportSpecifier(node); + case 228: + return getTargetOfExportSpecifier(node); + case 225: return getTargetOfExportAssignment(node); } } @@ -10740,10 +10874,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224) { + if (node.kind === 225) { checkExpressionCached(node.expression); } - else if (node.kind === 227) { + else if (node.kind === 228) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10753,17 +10887,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218); + importDeclaration = ts.getAncestor(entityName, 219); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 66 || entityName.parent.kind === 132) { + if (entityName.kind === 67 || entityName.parent.kind === 133) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 218); + ts.Debug.assert(entityName.parent.kind === 219); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10775,16 +10909,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66) { + if (name.kind === 67) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 || name.kind === 163) { - var left = name.kind === 132 ? name.left : name.expression; - var right = name.kind === 132 ? name.right : name.name; + else if (name.kind === 133 || name.kind === 164) { + var left = name.kind === 133 ? name.left : name.expression; + var right = name.kind === 133 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10807,35 +10941,24 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8) { + if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -10931,7 +11054,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10996,17 +11119,17 @@ var ts; } } switch (location_1.kind) { - case 245: + case 246: if (!ts.isExternalModule(location_1)) { break; } - case 215: + case 216: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211: case 212: + case 213: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11039,7 +11162,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11068,7 +11191,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11123,8 +11246,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 && declaration.name.kind === 8) || - (declaration.kind === 245 && ts.isExternalModule(declaration)); + return (declaration.kind === 216 && declaration.name.kind === 9) || + (declaration.kind === 246 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11156,11 +11279,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { meaning = 107455 | 1048576; } - else if (entityName.kind === 132 || entityName.kind === 163 || - entityName.parent.kind === 218) { + else if (entityName.kind === 133 || entityName.kind === 164 || + entityName.parent.kind === 219) { meaning = 1536; } else { @@ -11211,16 +11334,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157) { + while (node.kind === 158) { node = node.parent; } - if (node.kind === 213) { + if (node.kind === 214) { return getSymbolOfNode(node); } } return undefined; } - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -11229,10 +11351,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183: + case 184: return "(Anonymous class)"; - case 170: case 171: + case 172: return "(Anonymous function)"; } } @@ -11253,7 +11375,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11295,7 +11417,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 4194431) { + if (type.flags & 16777343) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -11319,23 +11441,23 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 14); - writeSpace(writer); - writePunctuation(writer, 21); - writeSpace(writer); writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23) { + if (delimiter !== 24) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 ? 0 : 64); + writeType(types[i], delimiter === 24 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -11343,22 +11465,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); } if (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeType(typeArguments[pos++], 0); while (pos < end) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 18); writePunctuation(writer, 19); + writePunctuation(writer, 20); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -11373,7 +11495,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } } @@ -11381,18 +11503,18 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18); - writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); } function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 16); - } - writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } + writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + if (flags & 64) { + writePunctuation(writer, 18); + } } function writeAnonymousType(type, flags) { var symbol = type.symbol; @@ -11409,7 +11531,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11430,7 +11552,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 || declaration.parent.kind === 216; + return declaration.parent.kind === 246 || declaration.parent.kind === 217; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11439,7 +11561,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98); + writeKeyword(writer, 99); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11455,74 +11577,74 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14); writePunctuation(writer, 15); + writePunctuation(writer, 16); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } } - writePunctuation(writer, 14); + writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 126); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -11534,27 +11656,27 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15); + writePunctuation(writer, 16); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -11568,7 +11690,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80); + writeKeyword(writer, 81); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11576,67 +11698,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21); + writePunctuation(writer, 22); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17); + writePunctuation(writer, 18); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 33); + writePunctuation(writer, 34); } else { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -11656,15 +11778,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -11673,12 +11792,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215) { - if (node.name.kind === 8) { + if (node.kind === 216) { + if (node.name.kind === 9) { return node; } } - else if (node.kind === 245) { + else if (node.kind === 246) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11721,60 +11840,60 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160: + case 161: return isDeclarationVisible(node.parent.parent); - case 208: + case 209: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 215: - case 211: + case 216: case 212: case 213: - case 210: case 214: - case 218: + case 211: + case 215: + case 219: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 138: - case 137: - case 142: - case 143: - case 140: case 139: + case 138: + case 143: + case 144: + case 141: + case 140: if (node.flags & (32 | 64)) { return false; } - case 141: - case 145: - case 144: + case 142: case 146: - case 135: - case 216: - case 149: + case 145: + case 147: + case 136: + case 217: case 150: - case 152: - case 148: + case 151: case 153: + case 149: case 154: case 155: case 156: case 157: + case 158: return isDeclarationVisible(node.parent); - case 220: case 221: - case 223: - return false; - case 134: - case 245: - return true; + case 222: case 224: return false; + case 135: + case 246: + return true; + case 225: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -11789,11 +11908,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); } var result = []; if (exportSymbol) { @@ -11816,29 +11938,55 @@ 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); + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 208 ? node.parent.parent.parent : node.parent; + return node.kind === 209 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11864,7 +12012,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var name_10 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_10.text) || isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || @@ -11877,9 +12025,6 @@ var ts; else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -11901,10 +12046,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 197) { + if (declaration.parent.parent.kind === 198) { return anyType; } - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 199) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11913,10 +12058,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var func = declaration.parent; - if (func.kind === 143 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); + if (func.kind === 144 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11929,9 +12074,12 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 243) { + if (declaration.kind === 244) { return checkIdentifier(declaration.name); } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } return undefined; } function getTypeFromBindingElement(element) { @@ -11958,7 +12106,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11973,7 +12121,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 + return pattern.kind === 159 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11983,15 +12131,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 242 ? getWidenedType(type) : type; - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12004,13 +12149,13 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241) { + if (declaration.parent.kind === 242) { return links.type = anyType; } - if (declaration.kind === 224) { + if (declaration.kind === 225) { return links.type = checkExpression(declaration.expression); } - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -12032,7 +12177,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142) { + if (accessor.kind === 143) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12045,11 +12190,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142); - var setter = ts.getDeclarationOfKind(symbol, 143); + var getter = ts.getDeclarationOfKind(symbol, 143); + var setter = ts.getDeclarationOfKind(symbol, 144); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12075,7 +12220,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142); + var getter_1 = ts.getDeclarationOfKind(symbol, 143); 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)); } } @@ -12164,9 +12309,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 || node.kind === 183 || - node.kind === 210 || node.kind === 170 || - node.kind === 140 || node.kind === 171) { + if (node.kind === 212 || node.kind === 184 || + node.kind === 211 || node.kind === 171 || + node.kind === 141 || node.kind === 172) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12175,15 +12320,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 || node.kind === 211 || - node.kind === 183 || node.kind === 213) { + if (node.kind === 213 || node.kind === 212 || + node.kind === 184 || node.kind === 214) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12219,7 +12364,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -12288,7 +12433,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12332,10 +12477,10 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12366,7 +12511,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12533,38 +12678,59 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; } function getUnionSignatures(types, kind) { var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } } } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; - } - } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); - } - return result; + return result || emptyArray; } function getUnionIndexType(types, kind) { var indexTypes = []; @@ -12701,9 +12867,6 @@ var ts; return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { - if (type.flags & 16384) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512) { do { type = getConstraintOfTypeParameter(type); @@ -12721,7 +12884,7 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 4194304) { + else if (type.flags & 16777216) { type = globalESSymbolType; } return type; @@ -12802,6 +12965,25 @@ var ts; } return undefined; } + function isKnownProperty(type, name) { + if (type.flags & 80896 && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); @@ -12857,12 +13039,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -12871,14 +13063,17 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8) { + if (param.type && param.type.kind === 9) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -12890,7 +13085,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147) { + if (declaration.type.kind === 148) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -12900,8 +13095,8 @@ var ts; } } else { - if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143); + if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -12919,19 +13114,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149: case 150: - case 210: - case 140: - case 139: + case 151: + case 211: case 141: - case 144: + case 140: + case 142: case 145: case 146: - case 142: + case 147: case 143: - case 170: + case 144: case 171: + case 172: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12945,7 +13140,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13001,7 +13196,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13015,7 +13210,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 125 : 127; + var syntaxKind = kind === 1 ? 126 : 128; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13044,13 +13239,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); } function getTypeListId(types) { switch (types.length) { @@ -13069,19 +13264,19 @@ var ts; return result; } } - function getWideningFlagsOfTypes(types) { + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13097,13 +13292,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 && n.typeName.kind === 66) { + if (n.kind === 149 && n.typeName.kind === 67) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13170,7 +13365,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 148 ? node.typeName : + var typeNameOrExpression = node.kind === 149 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13196,9 +13391,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211: case 212: - case 214: + case 213: + case 215: return declaration; } } @@ -13271,7 +13466,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -13297,20 +13492,68 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) { + return true; + } + if (source.flags & 524288 && target.flags & 80896) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -13333,25 +13576,21 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - function getUnionType(types, noSubtypeReduction) { + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -13359,25 +13598,11 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -13400,7 +13625,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -13436,45 +13661,45 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114: + case 115: return anyType; - case 127: - return stringType; - case 125: - return numberType; - case 117: - return booleanType; case 128: - return esSymbolType; - case 100: - return voidType; - case 8: - return getTypeFromStringLiteral(node); - case 148: - return getTypeFromTypeReference(node); - case 147: + return stringType; + case 126: + return numberType; + case 118: return booleanType; - case 185: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromTypeQueryNode(node); - case 153: - return getTypeFromArrayTypeNode(node); - case 154: - return getTypeFromTupleTypeNode(node); - case 155: - return getTypeFromUnionTypeNode(node); - case 156: - return getTypeFromIntersectionTypeNode(node); - case 157: - return getTypeFromTypeNode(node.type); + case 129: + return esSymbolType; + case 101: + return voidType; + case 9: + return getTypeFromStringLiteral(node); case 149: - case 150: + return getTypeFromTypeReference(node); + case 148: + return booleanType; + case 186: + return getTypeFromTypeReference(node); case 152: + return getTypeFromTypeQueryNode(node); + case 154: + return getTypeFromArrayTypeNode(node); + case 155: + return getTypeFromTupleTypeNode(node); + case 156: + return getTypeFromUnionTypeNode(node); + case 157: + return getTypeFromIntersectionTypeNode(node); + case 158: + return getTypeFromTypeNode(node.type); + case 150: + case 151: + case 153: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 66: - case 132: - var symbol = getSymbolInfo(node); + case 67: + case 133: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -13533,7 +13758,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -13542,6 +13767,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -13635,27 +13862,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170: case 171: + case 172: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 163: return ts.forEach(node.properties, isContextSensitive); - case 161: + case 162: return ts.forEach(node.elements, isContextSensitive); - case 179: + case 180: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178: - return node.operatorToken.kind === 50 && + case 179: + return node.operatorToken.kind === 51 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242: + case 243: return isContextSensitive(node.initializer); + case 141: case 140: - case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 169: + case 170: return isContextSensitive(node.expression); } return false; @@ -13729,99 +13956,135 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source === target) return -1; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1; - if (source === undefinedType) + if (source === numberType && target.flags & 128) return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; } + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 && target.flags & 512) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; @@ -13892,30 +14155,17 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1; - if (!(constraint && constraint.flags & 512)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0; } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); } function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { @@ -14092,22 +14342,12 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -14131,6 +14371,30 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -14219,7 +14483,7 @@ var ts; } var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); if (!related) { return 0; } @@ -14232,7 +14496,7 @@ var ts; return indexTypesIdenticalTo(0, source, target); } var targetType = getIndexTypeOfType(target, 0); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceType = getIndexTypeOfType(source, 0); if (!sourceType) { if (reportErrors) { @@ -14256,7 +14520,7 @@ var ts; return indexTypesIdenticalTo(1, source, target); } var targetType = getIndexTypeOfType(target, 1); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceStringType = getIndexTypeOfType(source, 0); var sourceNumberType = getIndexTypeOfType(source, 1); if (!(sourceStringType || sourceNumberType)) { @@ -14333,14 +14597,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } } var result = -1; if (source.typeParameters && target.typeParameters) { @@ -14360,16 +14628,18 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -14424,6 +14694,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -14451,7 +14738,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } @@ -14495,7 +14782,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -14509,22 +14796,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 139: case 138: - case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135: + case 136: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: - case 170: + case 144: case 171: + case 172: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14537,7 +14824,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -14573,7 +14860,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -14597,10 +14886,10 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -14624,6 +14913,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; @@ -14767,10 +15063,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 151: + case 152: return true; - case 66: - case 132: + case 67: + case 133: node = node.parent; continue; default: @@ -14810,12 +15106,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { + if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { var n = node.left; - while (n.kind === 169) { + while (n.kind === 170) { n = n.expression; } - if (n.kind === 66 && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 && getResolvedSymbol(n) === symbol) { return true; } } @@ -14829,82 +15125,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178: + case 179: return isAssignedInBinaryExpression(node); - case 208: - case 160: - return isAssignedInVariableDeclaration(node); - case 158: - case 159: + case 209: case 161: + return isAssignedInVariableDeclaration(node); + case 159: + case 160: case 162: case 163: case 164: case 165: case 166: - case 168: - case 186: + case 167: case 169: - case 176: - case 172: - case 175: - case 173: - case 174: + case 187: + case 170: case 177: - case 181: - case 179: + case 173: + case 176: + case 174: + case 175: + case 178: case 182: - case 189: + case 180: + case 183: case 190: - case 192: + case 191: case 193: case 194: case 195: case 196: case 197: case 198: - case 201: + case 199: case 202: case 203: - case 238: - case 239: case 204: + case 239: + case 240: case 205: case 206: - case 241: - case 230: + case 207: + case 242: case 231: - case 235: - case 236: case 232: + case 236: case 237: + case 233: + case 238: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - return getNarrowedTypeOfSymbol(symbol, node); - } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { @@ -14914,34 +15188,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193: + case 194: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 179: + case 180: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 178: + case 179: if (child === node.right) { - if (node.operatorToken.kind === 49) { + if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 50) { + else if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, false); } } break; - case 245: - case 215: - case 210: - case 140: - case 139: - case 142: - case 143: + case 246: + case 216: + case 211: case 141: + case 140: + case 143: + case 144: + case 142: break loop; } if (narrowedType !== type) { @@ -14955,21 +15229,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 173 || expr.right.kind !== 8) { + if (expr.left.kind !== 174 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32) { + if (expr.operatorToken.kind === 33) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -15006,7 +15280,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15039,11 +15313,14 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } if (originalType.flags & 16384) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; } return originalType; } @@ -15067,27 +15344,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165: + case 166: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169: + case 170: return narrowType(type, expr.expression, assumeTrue); - case 178: + case 179: var operator = expr.operatorToken.kind; - if (operator === 31 || operator === 32) { + if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88) { + else if (operator === 89) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176: - if (expr.operator === 47) { + case 177: + if (expr.operator === 48) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15099,7 +15376,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171) { + if (container.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15130,15 +15407,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 241) { + symbol.valueDeclaration.parent.kind === 242) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 209) { + while (container.kind !== 210) { container = container.parent; } container = container.parent; - if (container.kind === 190) { + if (container.kind === 191) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15156,7 +15433,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 138 || container.kind === 141) { + if (container.kind === 139 || container.kind === 142) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15167,29 +15444,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 171) { + if (container.kind === 172) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 215: + case 216: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 214: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 141: + case 142: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 139: case 138: - case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133: + case 134: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15204,86 +15481,92 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135) { + if (n.kind === 136) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 172) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; - if (isCallExpression) { - canUseSuperExpression = container.kind === 141; + if (!canUseSuperExpression) { + if (container && container.kind === 134) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + return container.kind === 142; } else { - needToCaptureLexicalThis = false; - while (container && container.kind === 171) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143; + container.kind === 143 || + container.kind === 144; } else { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143 || - container.kind === 138 || - container.kind === 137 || - container.kind === 141; + container.kind === 143 || + container.kind === 144 || + container.kind === 139 || + container.kind === 138 || + container.kind === 142; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 512; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256; - returnType = baseClassType; - } - if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } function getContextuallyTypedParameterType(parameter) { if (isFunctionExpressionOrArrowFunction(parameter.parent)) { @@ -15312,7 +15595,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15345,7 +15628,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 && node.parent.initializer === node) { + if (node.parent.kind === 136 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15354,8 +15637,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 141 || - functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { + functionDecl.kind === 142 || + functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15374,7 +15657,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167) { + if (template.parent.kind === 168) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15382,12 +15665,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 && operator <= 65) { + if (operator >= 55 && operator <= 66) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50) { + else if (operator === 51) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15474,7 +15757,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 235) { + if (expr.parent.kind === 236) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15484,7 +15767,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236) { + if (expr.kind === 237) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15502,38 +15785,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 160: - return getContextualTypeForInitializerExpression(node); - case 171: - case 201: - return getContextualTypeForReturnExpression(node); - case 181: - return getContextualTypeForYieldOperand(parent); - case 165: - case 166: - return getContextualTypeForArgument(parent, node); - case 168: - case 186: - return getTypeFromTypeNode(parent.type); - case 178: - return getContextualTypeForBinaryOperand(node); - case 242: - return getContextualTypeForObjectLiteralElement(parent); case 161: - return getContextualTypeForElementExpression(node); - case 179: - return getContextualTypeForConditionalOperand(node); - case 187: - ts.Debug.assert(parent.parent.kind === 180); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 172: + case 202: + return getContextualTypeForReturnExpression(node); + case 182: + return getContextualTypeForYieldOperand(parent); + case 166: + case 167: + return getContextualTypeForArgument(parent, node); case 169: + case 187: + return getTypeFromTypeNode(parent.type); + case 179: + return getContextualTypeForBinaryOperand(node); + case 243: + return getContextualTypeForObjectLiteralElement(parent); + case 162: + return getContextualTypeForElementExpression(node); + case 180: + return getContextualTypeForConditionalOperand(node); + case 188: + ts.Debug.assert(parent.parent.kind === 181); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 170: return getContextualType(parent); + case 238: case 237: - case 236: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15548,7 +15831,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 || node.kind === 171; + return node.kind === 171 || node.kind === 172; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15556,7 +15839,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15570,16 +15853,12 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - if (signatureList && - getSignaturesOfStructuredType(current, 0).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { return undefined; } else { @@ -15596,17 +15875,17 @@ var ts; return result; } function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { + if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { return true; } - if (parent.kind === 242) { + if (parent.kind === 243) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161) { + if (parent.kind === 162) { return isAssignmentTarget(parent); } return false; @@ -15625,7 +15904,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182) { + if (inDestructuringPattern && e.kind === 183) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -15637,7 +15916,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182; + hasSpreadElement = hasSpreadElement || e.kind === 183; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -15648,7 +15927,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -15663,7 +15942,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -15681,18 +15960,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 === 242 || - memberDecl.kind === 243 || + if (memberDecl.kind === 243 || + memberDecl.kind === 244 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242) { + if (memberDecl.kind === 243) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140) { + else if (memberDecl.kind === 141) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243); + ts.Debug.assert(memberDecl.kind === 244); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -15707,7 +15986,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); + ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15718,7 +15997,7 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 2097152 | (typeFlags & 1048576); + result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -15747,31 +16026,34 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66) { + if (lhs.kind === 67) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - checkJsxOpeningLikeElement(node.openingElement); + else { + getJsxElementTagSymbol(node.closingElement); + } for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237: + case 238: checkJsxExpression(child); break; - case 230: + case 231: checkJsxElement(child); break; - case 231: + case 232: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 233); + ts.Debug.assert(child.kind === 234); } } return jsxElementType || anyType; @@ -15780,7 +16062,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -15795,9 +16077,17 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -15860,7 +16150,7 @@ var ts; links.jsxFlags |= 2; return intrinsicElementsType.symbol; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -15870,26 +16160,26 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; - if (node.tagName.kind === 66) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } + var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4)) { - return undefined; - } + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { return anyType; @@ -15903,14 +16193,10 @@ var ts; signatures = getSignaturesOfType(valueType, 0); if (signatures.length === 0) { error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); @@ -15945,7 +16231,7 @@ var ts; if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -16013,7 +16299,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -16022,11 +16308,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235) { + if (node.attributes[i].kind === 236) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236); + ts.Debug.assert(node.attributes[i].kind === 237); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16052,7 +16338,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138; + return s.valueDeclaration ? s.valueDeclaration.kind : 139; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16060,11 +16346,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92) { - var errorNode = node.kind === 163 ? + if (left.kind === 93) { + var errorNode = node.kind === 164 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 140) { + if (getDeclarationKindFromSymbol(prop) !== 141) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16085,7 +16371,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16130,7 +16416,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 + var left = node.kind === 164 ? node.expression : node.left; var type = checkExpression(left); @@ -16145,7 +16431,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 && node.parent.expression === node) { + if (node.parent.kind === 167 && 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); @@ -16163,7 +16449,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -16181,7 +16467,7 @@ var ts; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -16201,7 +16487,7 @@ var ts; return unknownType; } function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 || indexArgumentExpression.kind === 7) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { @@ -16217,7 +16503,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 4194304) === 0) { + if ((expressionType.flags & 16777216) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -16241,10 +16527,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167) { + if (node.kind === 168) { checkExpression(node.template); } - else if (node.kind !== 136) { + else if (node.kind !== 137) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16266,19 +16552,19 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -16295,7 +16581,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182) { + if (arg && arg.kind === 183) { return i; } } @@ -16307,11 +16593,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167) { + if (node.kind === 168) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180) { + if (tagExpression.template.kind === 181) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16319,11 +16605,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10); + ts.Debug.assert(templateLiteral.kind === 11); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136) { + else if (node.kind === 137) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16331,7 +16617,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 166); + ts.Debug.assert(callExpression.kind === 167); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16384,7 +16670,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16431,11 +16717,11 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { - argType = arg.kind === 8 && !reportErrors + argType = arg.kind === 9 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -16450,16 +16736,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 167) { + if (node.kind === 168) { var template = node.template; args = [undefined]; - if (template.kind === 180) { + if (template.kind === 181) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136) { + else if (node.kind === 137) { return undefined; } else { @@ -16468,18 +16754,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136) { + if (node.kind === 137) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return 1; - case 138: + case 139: return 2; - case 140: - case 142: + case 141: case 143: + case 144: return signature.parameters.length >= 3 ? 3 : 2; - case 135: + case 136: return 3; } } @@ -16489,20 +16775,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 211: - case 183: + case 212: + case 184: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16511,27 +16797,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { return anyType; } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: var element = node; switch (element.name.kind) { - case 66: - case 7: + case 67: case 8: + case 9: return getStringLiteralType(element.name); - case 133: + case 134: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304)) { + if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; } else { @@ -16548,17 +16834,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135: + case 136: return numberType; - case 138: + case 139: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140: - case 142: + case 141: case 143: + case 144: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -16580,26 +16866,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 136 || - (argIndex === 0 && node.kind === 167)) { + if (node.kind === 137 || + (argIndex === 0 && node.kind === 168)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return node.expression; } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return node.template; } else { @@ -16607,12 +16893,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167; - var isDecorator = node.kind === 136; + var isTaggedTemplate = node.kind === 168; + var isDecorator = node.kind === 137; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 92) { + if (node.expression.kind !== 93) { ts.forEach(typeArguments, checkSourceElement); } } @@ -16675,6 +16961,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -16747,7 +17036,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -16792,7 +17081,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -16836,16 +17125,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135: + case 136: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140: - case 142: + case 141: case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -16873,16 +17162,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165) { + if (node.kind === 166) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166) { + else if (node.kind === 167) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 168) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136) { + else if (node.kind === 137) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -16894,15 +17183,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { return voidType; } - if (node.kind === 166) { + if (node.kind === 167) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 && - declaration.kind !== 145 && - declaration.kind !== 150) { + declaration.kind !== 142 && + declaration.kind !== 146 && + declaration.kind !== 151) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -16915,7 +17204,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -16934,13 +17223,22 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -16958,7 +17256,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189) { + if (func.body.kind !== 190) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17062,7 +17360,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205); + return (body.statements.length === 1) && (body.statements[0].kind === 206); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17071,7 +17369,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { return; } var bodyBlock = func.body; @@ -17084,9 +17382,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 !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170) { + if (!hasGrammarError && node.kind === 171) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17098,33 +17396,38 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 1024)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 1024)) { + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { + if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17141,7 +17444,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189) { + if (node.body.kind === 190) { checkSourceElement(node.body); } else { @@ -17173,17 +17476,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 66: { + case 67: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 163: { + case 164: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 164: + case 165: return true; - case 169: + case 170: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17191,22 +17494,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66: - case 163: { + case 67: + case 164: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 164: { + case 165: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8) { + if (symbol && index && index.kind === 9) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 169: + case 170: return isConstVariableReference(n.expression); default: return false; @@ -17249,17 +17552,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34: case 35: - case 48: - if (someConstituentTypeHasKind(operandType, 4194304)) { + case 36: + case 49: + if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47: + case 48: return booleanType; - case 39: case 40: + case 41: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17315,7 +17618,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 4194814)) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -17324,7 +17627,7 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { @@ -17336,7 +17639,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17361,8 +17664,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17387,7 +17690,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { + if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17400,14 +17703,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161) { + if (target.kind === 162) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17421,32 +17724,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { + if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36: - case 57: case 37: case 58: case 38: case 59: - case 35: - case 56: - case 41: + case 39: case 60: + case 36: + case 57: case 42: case 61: case 43: case 62: - case 45: - case 64: - case 46: - case 65: case 44: case 63: + case 46: + case 65: + case 47: + case 66: + case 45: + case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17465,8 +17768,8 @@ var ts; } } return numberType; - case 34: - case 55: + case 35: + case 56: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17490,42 +17793,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55) { + if (operator === 56) { checkAssignmentOperator(resultType); } return resultType; - case 24: - case 26: + case 25: case 27: case 28: + case 29: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 29: case 30: case 31: case 32: + case 33: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88: + case 89: return checkInstanceOfExpression(node, leftType, rightType); - case 87: + case 88: return checkInExpression(node, leftType, rightType); - case 49: - return rightType; case 50: - return getUnionType([leftType, rightType]); - case 54: - checkAssignmentOperator(rightType); return rightType; - case 23: + case 51: + return getUnionType([leftType, rightType]); + case 55: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : - someConstituentTypeHasKind(rightType, 4194304) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : + someConstituentTypeHasKind(rightType, 16777216) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17535,21 +17838,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 46: + case 65: + return 51; + case 47: + case 66: + return 33; case 45: case 64: return 50; - case 46: - case 65: - return 32; - case 44: - case 63: - return 49; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 && operator <= 65) { + if (produceDiagnostics && operator >= 55 && operator <= 66) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -17633,21 +17936,21 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -17663,7 +17966,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -17671,9 +17974,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 163 && node.parent.expression === node) || - (node.parent.kind === 164 && node.parent.expression === node) || - ((node.kind === 66 || node.kind === 132) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 && node.parent.expression === node) || + (node.parent.kind === 165 && node.parent.expression === node) || + ((node.kind === 67 || node.kind === 133) && 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); } @@ -17686,78 +17989,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66: + case 67: return checkIdentifier(node); - case 94: + case 95: return checkThisExpression(node); - case 92: + case 93: return checkSuperExpression(node); - case 90: + case 91: return nullType; - case 96: - case 81: + case 97: + case 82: return booleanType; - case 7: - return checkNumericLiteral(node); - case 180: - return checkTemplateExpression(node); case 8: - case 10: - return stringType; - case 9: - return globalRegExpType; - case 161: - return checkArrayLiteral(node, contextualMapper); - case 162: - return checkObjectLiteral(node, contextualMapper); - case 163: - return checkPropertyAccessExpression(node); - case 164: - return checkIndexedAccess(node); - case 165: - case 166: - return checkCallExpression(node); - case 167: - return checkTaggedTemplateExpression(node); - case 169: - return checkExpression(node.expression, contextualMapper); - case 183: - return checkClassExpression(node); - case 170: - case 171: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173: - return checkTypeOfExpression(node); - case 168: - case 186: - return checkAssertion(node); - case 172: - return checkDeleteExpression(node); - case 174: - return checkVoidExpression(node); - case 175: - return checkAwaitExpression(node); - case 176: - return checkPrefixUnaryExpression(node); - case 177: - return checkPostfixUnaryExpression(node); - case 178: - return checkBinaryExpression(node, contextualMapper); - case 179: - return checkConditionalExpression(node, contextualMapper); - case 182: - return checkSpreadElementExpression(node, contextualMapper); - case 184: - return undefinedType; + return checkNumericLiteral(node); case 181: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 162: + return checkArrayLiteral(node, contextualMapper); + case 163: + return checkObjectLiteral(node, contextualMapper); + case 164: + return checkPropertyAccessExpression(node); + case 165: + return checkIndexedAccess(node); + case 166: + case 167: + return checkCallExpression(node); + case 168: + return checkTaggedTemplateExpression(node); + case 170: + return checkExpression(node.expression, contextualMapper); + case 184: + return checkClassExpression(node); + case 171: + case 172: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 174: + return checkTypeOfExpression(node); + case 169: + case 187: + return checkAssertion(node); + case 173: + return checkDeleteExpression(node); + case 175: + return checkVoidExpression(node); + case 176: + return checkAwaitExpression(node); + case 177: + return checkPrefixUnaryExpression(node); + case 178: + return checkPostfixUnaryExpression(node); + case 179: + return checkBinaryExpression(node, contextualMapper); + case 180: + return checkConditionalExpression(node, contextualMapper); + case 183: + return checkSpreadElementExpression(node, contextualMapper); + case 185: + return undefinedType; + case 182: return checkYieldExpression(node); - case 237: + case 238: return checkJsxExpression(node); - case 230: - return checkJsxElement(node); case 231: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 232: + return checkJsxSelfClosingElement(node); + case 233: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -17782,7 +18085,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -17797,15 +18100,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 || - node.kind === 210 || - node.kind === 170; + return node.kind === 141 || + node.kind === 211 || + node.kind === 171; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 && + if (param.name.kind === 67 && param.name.text === parameter.text) { return i; } @@ -17815,30 +18118,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { + case 172: + case 145: + case 211: case 171: - case 144: - case 210: - case 170: - case 149: + case 150: + case 141: case 140: - case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 146) { + if (node.kind === 147) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || - node.kind === 144 || node.kind === 141 || - node.kind === 145) { + else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || + node.kind === 145 || node.kind === 142 || + node.kind === 146) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147) { + if (node.type.kind === 148) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -17847,7 +18150,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -17857,19 +18160,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 || - param.name.kind === 159) { + if (param.name.kind === 159 || + param.name.kind === 160) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 && + if (element.name.kind === 67 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 || - element.name.kind === 158) { + else if (element.name.kind === 160 || + element.name.kind === 159) { checkBindingPattern(element.name); } } @@ -17893,10 +18196,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145: + case 146: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144: + case 145: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -17918,7 +18221,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212) { + if (node.kind === 213) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -17933,7 +18236,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127: + case 128: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -17941,7 +18244,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -17981,48 +18284,69 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 && n.expression.kind === 92; + return n.kind === 166 && n.expression.kind === 93; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170: - case 210: - case 171: - case 162: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94) { + if (n.kind === 95) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 && n.kind !== 210) { + else if (n.kind !== 171 && n.kind !== 211) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 && + return n.kind === 139 && !(n.flags & 128) && !!n.initializer; } - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || 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 !== 192 || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { 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 { - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -18030,13 +18354,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142) { + if (node.kind === 143) { 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 === 142 ? 143 : 142; + var otherKind = node.kind === 143 ? 144 : 143; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18121,9 +18445,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); - var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); + var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18141,7 +18465,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18217,7 +18541,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 === 140 || node.kind === 139); + ts.Debug.assert(node.kind === 141 || node.kind === 140); 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); @@ -18249,11 +18573,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { + if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18332,35 +18656,50 @@ var ts; } var exportedDeclarationSpaces = 0; var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212: + case 213: return 2097152; - case 215: - return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 + case 216: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 211: - case 214: + case 212: + case 215: return 2097152 | 1048576; - case 218: + case 219: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18495,22 +18834,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211: + case 212: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135: + case 136: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140: - case 142: + case 141: case 143: + case 144: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18519,7 +18858,7 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 148) { + if (node && node.kind === 149) { var root = getFirstIdentifier(node.typeName); var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { @@ -18529,19 +18868,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138: + case 139: checkTypeNodeAsExpression(node.type); break; - case 135: + case 136: checkTypeNodeAsExpression(node.type); break; - case 140: - checkTypeNodeAsExpression(node.type); - break; - case 142: + case 141: checkTypeNodeAsExpression(node.type); break; case 143: + checkTypeNodeAsExpression(node.type); + break; + case 144: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18564,24 +18903,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 211: + case 212: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140: + case 141: checkParameterTypeAnnotationsAsExpressions(node); + case 144: case 143: - case 142: - case 138: - case 135: + case 139: + case 136: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135) { + if (node.kind === 136) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18604,7 +18943,7 @@ var ts; } emitAwaiter = true; } - if (node.name && node.name.kind === 133) { + if (node.name && node.name.kind === 134) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -18639,11 +18978,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 189) { + if (node.kind === 190) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216) { + if (ts.isFunctionBlock(node) || node.kind === 217) { checkFunctionAndClassExpressionBodies(node); } } @@ -18661,19 +19000,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 || - node.kind === 137 || + if (node.kind === 139 || + node.kind === 138 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || - node.kind === 143) { + node.kind === 143 || + node.kind === 144) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -18687,7 +19026,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 66; + var isDeclaration_1 = node.kind !== 67; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -18708,7 +19047,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66; + var isDeclaration_2 = node.kind !== 67; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -18721,11 +19060,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 245 && ts.isExternalModule(parent)) { + if (parent.kind === 246 && 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)); } } @@ -18736,7 +19075,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 208 && !node.initializer) { + if (node.kind === 209 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -18746,15 +19085,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); - var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); + var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 189 && ts.isFunctionLike(container.parent) || + (container.kind === 190 && ts.isFunctionLike(container.parent) || + container.kind === 217 || container.kind === 216 || - container.kind === 215 || - container.kind === 245); + container.kind === 246); if (!namesShareScope) { var name_14 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); @@ -18764,16 +19103,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135) { + if (ts.getRootDeclaration(node).kind !== 136) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66) { + if (n.kind === 67) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135) { + if (referencedSymbol.valueDeclaration.kind === 136) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -18793,7 +19132,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -18802,7 +19141,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -18830,9 +19169,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 138 && node.kind !== 137) { + if (node.kind !== 139 && node.kind !== 138) { checkExportsOnMergedDeclarations(node); - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -18853,7 +19192,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 162) { + if (node.modifiers && node.parent.kind === 163) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -18886,12 +19225,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209) { + if (node.initializer && node.initializer.kind === 210) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -18906,13 +19245,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -18927,7 +19266,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { 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); @@ -18937,7 +19276,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19099,7 +19438,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); + return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19117,10 +19456,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 143) { + if (func.kind === 144) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141) { + else if (func.kind === 142) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19153,7 +19492,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 239 && !hasDuplicateDefaultClause) { + if (clause.kind === 240 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19165,7 +19504,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238) { + if (produceDiagnostics && clause.kind === 239) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19182,7 +19521,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 && current.label.text === node.label.text) { + if (current.kind === 205 && 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; @@ -19208,7 +19547,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66) { + if (catchClause.variableDeclaration.name.kind !== 67) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19276,7 +19615,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19429,7 +19768,7 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } @@ -19470,7 +19809,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 || kind === 143; + return kind === 143 || kind === 144; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19536,7 +19875,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); 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); @@ -19554,7 +19893,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -19586,28 +19925,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -19618,22 +19941,42 @@ var ts; }); nodeLinks.flags |= 8192; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34: return value; - case 35: return -value; - case 48: return ~value; + case 35: return value_1; + case 36: return -value_1; + case 49: return ~value_1; } return undefined; - case 178: + case 179: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -19643,39 +19986,39 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45: return left | right; - case 44: return left & right; - case 42: return left >> right; - case 43: return left >>> right; - case 41: return left << right; - case 46: return left ^ right; - case 36: return left * right; - case 37: return left / right; - case 34: return left + right; - case 35: return left - right; - case 38: return left % right; + case 46: return left | right; + case 45: return left & right; + case 43: return left >> right; + case 44: return left >>> right; + case 42: return left << right; + case 47: return left ^ right; + case 37: return left * right; + case 38: return left / right; + case 35: return left + right; + case 36: return left - right; + case 39: return left % right; } return undefined; - case 7: + case 8: return +e.text; - case 169: + case 170: return evalConstant(e.expression); - case 66: + case 67: + case 165: case 164: - case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66) { - enumType = currentType; + if (e.kind === 67) { + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164) { + if (e.kind === 165) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8) { + e.argumentExpression.kind !== 9) { return undefined; } expression = e.expression; @@ -19687,25 +20030,25 @@ var ts; } var current = expression; while (current) { - if (current.kind === 66) { + if (current.kind === 67) { break; } - else if (current.kind === 163) { + else if (current.kind === 164) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); - if (!(enumType.symbol && (enumType.symbol.flags & 384))) { + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -19714,6 +20057,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -19747,7 +20092,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 214) { + if (declaration.kind !== 215) { return false; } var enumDeclaration = declaration; @@ -19770,8 +20115,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 || - (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 || + (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -19793,7 +20138,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 8; + var isAmbientExternalModule = node.name.kind === 9; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -19801,7 +20146,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -19822,7 +20167,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 211); + var mergedClass = ts.getDeclarationOfKind(symbol, 212); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -19841,28 +20186,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132) { + if (node.kind === 133) { node = node.left; } - else if (node.kind === 163) { + else if (node.kind === 164) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66); + ts.Debug.assert(node.kind === 67); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 ? + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -19881,7 +20226,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 ? + var message = node.kind === 228 ? 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)); @@ -19907,7 +20252,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -19942,7 +20287,7 @@ var ts; } } else { - if (languageVersion >= 2) { + if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.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); } } @@ -19958,8 +20303,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -19972,7 +20317,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { + if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -19986,15 +20331,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 245 ? node.parent : node.parent.parent; - if (container.kind === 215 && container.name.kind === 66) { + var container = node.parent.kind === 246 ? node.parent : node.parent.parent; + if (container.kind === 216 && container.name.kind === 67) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { markExportAsReferenced(node); } else { @@ -20011,10 +20356,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245) { + if (node.kind === 246) { return node.statements; } - if (node.kind === 215 && node.body.kind === 216) { + if (node.kind === 216 && node.body.kind === 217) { return node.body.statements; } return emptyArray; @@ -20051,182 +20396,181 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134: - return checkTypeParameter(node); case 135: + return checkTypeParameter(node); + case 136: return checkParameter(node); + case 139: case 138: - case 137: return checkPropertyDeclaration(node); - case 149: case 150: - case 144: + case 151: case 145: - return checkSignatureDeclaration(node); case 146: return checkSignatureDeclaration(node); - case 140: - case 139: - return checkMethodDeclaration(node); - case 141: - return checkConstructorDeclaration(node); - case 142: - case 143: - return checkAccessorDeclaration(node); - case 148: - return checkTypeReferenceNode(node); case 147: + return checkSignatureDeclaration(node); + case 141: + case 140: + return checkMethodDeclaration(node); + case 142: + return checkConstructorDeclaration(node); + case 143: + case 144: + return checkAccessorDeclaration(node); + case 149: + return checkTypeReferenceNode(node); + case 148: return checkTypePredicate(node); - case 151: - return checkTypeQuery(node); case 152: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 153: - return checkArrayType(node); + return checkTypeLiteral(node); case 154: - return checkTupleType(node); + return checkArrayType(node); case 155: + return checkTupleType(node); case 156: - return checkUnionOrIntersectionType(node); case 157: + return checkUnionOrIntersectionType(node); + case 158: return checkSourceElement(node.type); - case 210: - return checkFunctionDeclaration(node); - case 189: - case 216: - return checkBlock(node); - case 190: - return checkVariableStatement(node); - case 192: - return checkExpressionStatement(node); - case 193: - return checkIfStatement(node); - case 194: - return checkDoStatement(node); - case 195: - return checkWhileStatement(node); - case 196: - return checkForStatement(node); - case 197: - return checkForInStatement(node); - case 198: - return checkForOfStatement(node); - case 199: - case 200: - return checkBreakOrContinueStatement(node); - case 201: - return checkReturnStatement(node); - case 202: - return checkWithStatement(node); - case 203: - return checkSwitchStatement(node); - case 204: - return checkLabeledStatement(node); - case 205: - return checkThrowStatement(node); - case 206: - return checkTryStatement(node); - case 208: - return checkVariableDeclaration(node); - case 160: - return checkBindingElement(node); case 211: - return checkClassDeclaration(node); - case 212: - return checkInterfaceDeclaration(node); - case 213: - return checkTypeAliasDeclaration(node); - case 214: - return checkEnumDeclaration(node); - case 215: - return checkModuleDeclaration(node); - case 219: - return checkImportDeclaration(node); - case 218: - return checkImportEqualsDeclaration(node); - case 225: - return checkExportDeclaration(node); - case 224: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 190: + case 217: + return checkBlock(node); case 191: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 193: + return checkExpressionStatement(node); + case 194: + return checkIfStatement(node); + case 195: + return checkDoStatement(node); + case 196: + return checkWhileStatement(node); + case 197: + return checkForStatement(node); + case 198: + return checkForInStatement(node); + case 199: + return checkForOfStatement(node); + case 200: + case 201: + return checkBreakOrContinueStatement(node); + case 202: + return checkReturnStatement(node); + case 203: + return checkWithStatement(node); + case 204: + return checkSwitchStatement(node); + case 205: + return checkLabeledStatement(node); + case 206: + return checkThrowStatement(node); case 207: + return checkTryStatement(node); + case 209: + return checkVariableDeclaration(node); + case 161: + return checkBindingElement(node); + case 212: + return checkClassDeclaration(node); + case 213: + return checkInterfaceDeclaration(node); + case 214: + return checkTypeAliasDeclaration(node); + case 215: + return checkEnumDeclaration(node); + case 216: + return checkModuleDeclaration(node); + case 220: + return checkImportDeclaration(node); + case 219: + return checkImportEqualsDeclaration(node); + case 226: + return checkExportDeclaration(node); + case 225: + return checkExportAssignment(node); + case 192: checkGrammarStatementInAmbientContext(node); return; - case 228: + case 208: + checkGrammarStatementInAmbientContext(node); + return; + case 229: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170: case 171: + case 172: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183: + case 184: ts.forEach(node.members, checkSourceElement); break; + case 141: case 140: - case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141: case 142: case 143: - case 210: + case 144: + case 211: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202: + case 203: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136: - case 135: - case 138: case 137: - case 158: + case 136: + case 139: + case 138: case 159: case 160: case 161: case 162: - case 242: case 163: + case 243: case 164: case 165: case 166: case 167: - case 180: - case 187: case 168: - case 186: + case 181: + case 188: case 169: - case 173: + case 187: + case 170: case 174: case 175: - case 172: case 176: + case 173: case 177: case 178: case 179: + case 180: + case 183: case 182: - case 181: - case 189: - case 216: case 190: - case 192: + case 217: + case 191: case 193: case 194: case 195: @@ -20236,27 +20580,28 @@ var ts; case 199: case 200: case 201: - case 203: - case 217: - case 238: - case 239: + case 202: case 204: + case 218: + case 239: + case 240: case 205: case 206: - case 241: - case 208: + case 207: + case 242: case 209: - case 211: - case 214: - case 244: - case 224: + case 210: + case 212: + case 215: case 245: - case 237: - case 230: + case 225: + case 246: + case 238: case 231: - case 235: - case 236: case 232: + case 236: + case 237: + case 233: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20334,7 +20679,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 && node.parent.statement === node) { + if (node.parent.kind === 203 && node.parent.statement === node) { return true; } node = node.parent; @@ -20356,34 +20701,37 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) { break; } - case 215: + case 216: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 214: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 183: + case 184: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 211: case 212: + case 213: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 170: + case 171: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -20407,42 +20755,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 && + return name.kind === 67 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134: - case 211: + case 135: case 212: case 213: case 214: + case 215: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132) { + while (node.parent && node.parent.kind === 133) { node = node.parent; } - return node.parent && node.parent.kind === 148; + return node.parent && node.parent.kind === 149; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163) { + while (node.parent && node.parent.kind === 164) { node = node.parent; } - return node.parent && node.parent.kind === 185; + return node.parent && node.parent.kind === 186; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132) { + while (nodeOnRightSide.parent.kind === 133) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218) { + if (nodeOnRightSide.parent.kind === 219) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20454,10 +20802,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224) { + if (entityName.parent.kind === 225) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 163) { + if (entityName.kind !== 164) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20466,29 +20814,31 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 ? 793056 : 1536; + var meaning = entityName.parent.kind === 186 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + else if ((entityName.parent.kind === 233) || + (entityName.parent.kind === 232) || + (entityName.parent.kind === 235)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 66) { + if (entityName.kind === 67) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163) { + else if (entityName.kind === 164) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132) { + else if (entityName.kind === 133) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20497,54 +20847,65 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 ? 793056 : 1536; + var meaning = entityName.parent.kind === 149 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235) { + else if (entityName.parent.kind === 236) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 148) { return resolveEntityName(entityName, 1); } return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { return undefined; } if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 && + node.parent.parent.kind === 159 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66: - case 163: - case 132: + case 67: + case 164: + case 133: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94: - case 92: + case 95: + case 93: var type = checkExpression(node); return type.symbol; - case 118: + case 119: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141) { + if (constructorDeclaration && constructorDeclaration.kind === 142) { return constructorDeclaration.parent.symbol; } return undefined; - case 8: + case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 || node.parent.kind === 225) && + ((node.parent.kind === 220 || node.parent.kind === 226) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - case 7: - if (node.parent.kind === 164 && node.parent.argumentExpression === node) { + case 8: + if (node.parent.kind === 165 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20558,7 +20919,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 243) { + if (location && location.kind === 244) { return resolveEntityName(location.name, 107455); } return undefined; @@ -20581,7 +20942,7 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { @@ -20589,14 +20950,14 @@ var ts; return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -20655,11 +21016,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -20672,11 +21033,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189: - case 217: - case 196: + case 190: + case 218: case 197: case 198: + case 199: return true; } return false; @@ -20702,22 +21063,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218: - case 220: + case 219: case 221: - case 223: - case 227: + case 222: + case 224: + case 228: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225: + case 226: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224: - return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225: + return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -20728,7 +21089,10 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -20762,7 +21126,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244) { + if (node.kind === 245) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -20776,13 +21140,14 @@ var ts; function isFunctionType(type) { return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(node) { - var symbol = resolveEntityName(node.typeName, 107455, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + var typeSymbol = resolveEntityName(typeName, 793056, true); + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -20804,7 +21169,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304)) { + else if (allConstituentTypesHaveKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -20846,13 +21211,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && 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 !== 241; + symbol.valueDeclaration.parent.kind !== 242; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -20892,7 +21257,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -20973,7 +21339,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 === 142 || node.kind === 143) { + else if (node.kind === 143 || node.kind === 144) { 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); @@ -20983,38 +21349,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142: case 143: - case 141: - case 138: - case 137: - case 140: + case 144: + case 142: case 139: - case 146: - case 215: + case 138: + case 141: + case 140: + case 147: + case 216: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 135: - break; - case 210: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && - node.parent.kind !== 216 && node.parent.kind !== 245) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 136: break; case 211: - case 212: - case 190: - case 213: - if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 212: + case 213: + case 191: case 214: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && - node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 215: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21029,14 +21395,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 110: case 109: case 108: - case 107: var text = void 0; - if (modifier.kind === 109) { + if (modifier.kind === 110) { text = "public"; } - else if (modifier.kind === 108) { + else if (modifier.kind === 109) { text = "protected"; lastProtected = modifier; } @@ -21053,11 +21419,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 107) { + if (modifier.kind === 108) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21066,17 +21432,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110: + case 111: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21085,7 +21451,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 79: + case 80: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21098,42 +21464,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 119: + case 120: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 112: + case 113: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211) { - if (node.kind !== 140) { + if (node.kind !== 212) { + if (node.kind !== 141) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + if (!(node.parent.kind === 212 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21145,14 +21511,14 @@ var ts; } flags |= 256; break; - case 115: + case 116: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21160,7 +21526,7 @@ var ts; break; } } - if (node.kind === 141) { + if (node.kind === 142) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21178,10 +21544,10 @@ var ts; } return; } - else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + else if ((node.kind === 220 || node.kind === 219) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21193,10 +21559,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140: - case 210: - case 170: + case 141: + case 211: case 171: + case 172: if (!node.asteriskToken) { return false; } @@ -21244,16 +21610,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -21263,7 +21627,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171) { + if (node.kind === 172) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21298,7 +21662,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 !== 127 && parameter.type.kind !== 125) { + if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21330,7 +21694,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184) { + if (arg.kind === 185) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21357,7 +21721,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21370,7 +21734,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21385,14 +21749,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21401,19 +21765,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 133) { + if (node.kind !== 134) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 || - node.kind === 170 || - node.kind === 140); + ts.Debug.assert(node.kind === 211 || + node.kind === 171 || + node.kind === 141); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21439,26 +21803,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 || - name_16.kind === 133) { + if (prop.kind === 185 || + name_16.kind === 134) { checkGrammarComputedPropertyName(name_16); continue; } var currentKind = void 0; - if (prop.kind === 242 || prop.kind === 243) { + if (prop.kind === 243 || prop.kind === 244) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7) { + if (name_16.kind === 8) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140) { + else if (prop.kind === 141) { currentKind = Property; } - else if (prop.kind === 142) { + else if (prop.kind === 143) { currentKind = GetAccessor; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = SetAccesor; } else { @@ -21490,7 +21854,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236) { + if (attr.kind === 237) { continue; } var jsxAttr = attr; @@ -21502,7 +21866,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 && !initializer.expression) { + if (initializer && initializer.kind === 238 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21511,24 +21875,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209) { + if (forInOrOfStatement.initializer.kind === 210) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? 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 === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? 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 === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? 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); @@ -21551,10 +21915,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 && accessor.parameters.length) { + else if (kind === 143 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143) { + else if (kind === 144) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -21579,7 +21943,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -21589,7 +21953,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162) { + if (node.parent.kind === 163) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -21608,22 +21972,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 === 212) { + else if (node.parent.kind === 213) { 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 === 152) { + else if (node.parent.kind === 153) { 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 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return true; - case 204: + case 205: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -21635,9 +21999,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204: + case 205: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 199 + var isMisplacedContinueLabel = node.kind === 200 && !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); @@ -21645,8 +22009,8 @@ var ts; return false; } break; - case 203: - if (node.kind === 200 && !node.label) { + case 204: + if (node.kind === 201 && !node.label) { return false; } break; @@ -21659,13 +22023,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 + var message = node.kind === 201 ? 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 === 200 + var message = node.kind === 201 ? 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); @@ -21677,7 +22041,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 || node.name.kind === 158) { + if (node.name.kind === 160 || node.name.kind === 159) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -21686,7 +22050,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { + if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -21706,7 +22070,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66) { + if (name.kind === 67) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -21715,7 +22079,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -21732,15 +22096,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193: case 194: case 195: - case 202: case 196: + case 203: case 197: case 198: + case 199: return false; - case 204: + case 205: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -21756,13 +22120,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176) { + if (expression.kind === 177) { var unaryExpression = expression; - if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; } } - if (expression.kind === 7) { + if (expression.kind === 8) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); } return false; @@ -21775,7 +22139,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 === 133) { + if (node.name.kind === 134) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -21818,7 +22182,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -21838,12 +22202,12 @@ var ts; return true; } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { 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 === 152) { + else if (node.parent.kind === 153) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -21853,11 +22217,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 212 || + if (node.kind === 213 || + node.kind === 220 || node.kind === 219 || - node.kind === 218 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -21867,7 +22231,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 === 190) { + if (ts.isDeclaration(decl) || decl.kind === 191) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -21886,7 +22250,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 === 189 || node.parent.kind === 216 || node.parent.kind === 245) { + if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { 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); @@ -21959,7 +22323,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219); + ts.Debug.assert(aliasEmitInfo.node.kind === 220); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22032,10 +22396,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208) { + if (declaration.kind === 209) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { + else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22046,7 +22410,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219) { + if (moduleElementEmitInfo.node.kind === 220) { moduleElementEmitInfo.isVisible = true; } else { @@ -22054,12 +22418,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22146,62 +22510,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 8: + case 126: + case 118: + case 129: + case 101: + case 9: return writeTextOfNode(currentSourceFile, type); - case 185: + case 186: return emitExpressionWithTypeArguments(type); - case 148: - return emitTypeReference(type); - case 151: - return emitTypeQuery(type); - case 153: - return emitArrayType(type); - case 154: - return emitTupleType(type); - case 155: - return emitUnionType(type); - case 156: - return emitIntersectionType(type); - case 157: - return emitParenType(type); case 149: - case 150: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 152: + return emitTypeQuery(type); + case 154: + return emitArrayType(type); + case 155: + return emitTupleType(type); + case 156: + return emitUnionType(type); + case 157: + return emitIntersectionType(type); + case 158: + return emitParenType(type); + case 150: + case 151: + return emitSignatureDeclarationWithJsDocComments(type); + case 153: return emitTypeLiteral(type); - case 66: + case 67: return emitEntityName(type); - case 132: + case 133: return emitEntityName(type); - case 147: + case 148: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66) { + if (entityName.kind === 67) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 ? entityName.left : entityName.expression; - var right = entityName.kind === 132 ? entityName.right : entityName.name; + var left = entityName.kind === 133 ? entityName.left : entityName.expression; + var right = entityName.kind === 133 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); + ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22277,7 +22641,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22295,7 +22659,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22313,10 +22677,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 || - (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 || + (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22325,7 +22689,7 @@ var ts; }); } else { - if (node.kind === 219) { + if (node.kind === 220) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22343,23 +22707,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210: - return writeFunctionDeclaration(node); - case 190: - return writeVariableStatement(node); - case 212: - return writeInterfaceDeclaration(node); case 211: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 191: + return writeVariableStatement(node); case 213: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 212: + return writeClassDeclaration(node); case 214: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 215: + return writeEnumDeclaration(node); + case 216: return writeModuleDeclaration(node); - case 218: - return writeImportEqualsDeclaration(node); case 219: + return writeImportEqualsDeclaration(node); + case 220: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22373,7 +22737,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22420,7 +22784,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22446,7 +22810,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22502,7 +22866,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216) { + while (node.body.kind !== 217) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22519,14 +22883,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -22563,7 +22931,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 && (node.parent.flags & 32); + return node.parent.kind === 141 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22573,15 +22941,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - (node.parent.parent && node.parent.parent.kind === 152)) { - ts.Debug.assert(node.parent.kind === 140 || - node.parent.kind === 139 || - node.parent.kind === 149 || + if (node.parent.kind === 150 || + node.parent.kind === 151 || + (node.parent.parent && node.parent.parent.kind === 153)) { + ts.Debug.assert(node.parent.kind === 141 || + node.parent.kind === 140 || node.parent.kind === 150 || - node.parent.kind === 144 || - node.parent.kind === 145); + node.parent.kind === 151 || + node.parent.kind === 145 || + node.parent.kind === 146); emitType(node.constraint); } else { @@ -22591,31 +22959,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 211: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 146: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 141: case 140: - case 139: 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 === 211) { + else if (node.parent.parent.kind === 212) { 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 210: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -22645,7 +23013,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 211) { + if (node.parent.parent.kind === 212) { 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; @@ -22725,16 +23093,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { + if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -22743,14 +23111,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208) { + if (node.kind === 209) { 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 === 138 || node.kind === 137) { + else if (node.kind === 139 || node.kind === 138) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -22758,7 +23126,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 === 211) { + else if (node.parent.kind === 212) { 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 : @@ -22784,7 +23152,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { elements.push(element); } } @@ -22850,7 +23218,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -22863,7 +23231,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 + return accessor.kind === 143 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -22872,7 +23240,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143) { + if (accessorWithTypeAnnotation.kind === 144) { 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 : @@ -22918,17 +23286,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210) { + if (node.kind === 211) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140) { + else if (node.kind === 141) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210) { + if (node.kind === 211) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141) { + else if (node.kind === 142) { write("constructor"); } else { @@ -22945,11 +23313,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 145 || node.kind === 150) { + if (node.kind === 146 || node.kind === 151) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146) { + if (node.kind === 147) { write("["); } else { @@ -22958,20 +23326,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146) { + if (node.kind === 147) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { + var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 && !(node.flags & 32)) { + else if (node.kind !== 142 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -22982,23 +23350,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145: + case 146: 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 144: + case 145: 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 146: + case 147: 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 141: case 140: - case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23006,7 +23374,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 === 211) { + else if (node.parent.kind === 212) { 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 : @@ -23019,7 +23387,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210: + case 211: 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 : @@ -23047,13 +23415,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - node.parent.parent.kind === 152) { + if (node.parent.kind === 150 || + node.parent.kind === 151 || + node.parent.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23069,22 +23437,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141: + case 142: 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 145: + case 146: 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 144: + case 145: 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 141: case 140: - case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23092,7 +23460,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 === 211) { + else if (node.parent.parent.kind === 212) { 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 : @@ -23104,7 +23472,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 210: + case 211: 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 : @@ -23115,12 +23483,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 158) { + if (bindingPattern.kind === 159) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159) { + else if (bindingPattern.kind === 160) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23139,21 +23507,20 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184) { + if (bindingElement.kind === 185) { write(" "); } - else if (bindingElement.kind === 160) { + else if (bindingElement.kind === 161) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66); + ts.Debug.assert(bindingElement.name.kind === 67); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23165,39 +23532,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210: - case 215: - case 218: - case 212: case 211: - case 213: - case 214: - return emitModuleElement(node, isModuleElementVisible(node)); - case 190: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 216: case 219: + case 213: + case 212: + case 214: + case 215: + return emitModuleElement(node, isModuleElementVisible(node)); + case 191: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 220: return emitModuleElement(node, !node.importClause); - case 225: + case 226: return emitExportDeclaration(node); + case 142: case 141: case 140: - case 139: return writeFunctionDeclaration(node); - case 145: - case 144: case 146: + case 145: + case 147: return emitSignatureDeclarationWithJsDocComments(node); - case 142: case 143: + case 144: return emitAccessorDeclaration(node); + case 139: case 138: - case 137: return emitPropertyDeclaration(node); - case 244: - return emitEnumMemberDeclaration(node); - case 224: - return emitExportAssignment(node); case 245: + return emitEnumMemberDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFile(node); } } @@ -23206,7 +23573,7 @@ var ts; ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } @@ -23262,17 +23629,17 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); @@ -23325,7 +23692,7 @@ var ts; var writeEmittedFiles = writeJavaScriptFile; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -23396,7 +23763,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? + var baseName = expr.kind === 9 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -23408,19 +23775,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66: + case 67: return makeUniqueName(node.text); + case 216: case 215: - case 214: return generateNameForModuleOrEnum(node); - case 219: - case 225: + case 220: + case 226: return generateNameForImportOrExportDeclaration(node); - case 210: case 211: - case 224: + case 212: + case 225: return generateNameForExportDefault(); - case 183: + case 184: return generateNameForClassExpression(); } } @@ -23474,7 +23841,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -23559,7 +23926,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_21 = node.name; - if (!name_21 || name_21.kind !== 133) { + if (!name_21 || name_21.kind !== 134) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -23576,18 +23943,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 210 || - node.kind === 170 || + else if (node.kind === 211 || + node.kind === 171 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || node.kind === 143 || - node.kind === 215 || - node.kind === 211 || - node.kind === 214) { + node.kind === 144 || + node.kind === 216 || + node.kind === 212 || + node.kind === 215) { if (node.name) { var name_22 = node.name; - scopeName = name_22.kind === 133 + scopeName = name_22.kind === 134 ? ts.getTextOfNode(name_22) : node.name.text; } @@ -23686,7 +24053,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245) { + if (node.kind !== 246) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -23697,8 +24064,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -23710,7 +24080,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66); + var result = ts.createSynthesizedNode(67); result.text = makeTempVariableName(flags); return result; } @@ -23820,7 +24190,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -23846,7 +24218,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 && text.length > 1) { + if (node.kind === 8 && text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: @@ -23859,7 +24231,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -23871,23 +24243,23 @@ var ts; } function getLiteralText(node) { if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } if (node.parent) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); } switch (node.kind) { - case 8: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10: - return getQuotedEscapedLiteralText('`', node.text, '`'); + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); case 11: - return getQuotedEscapedLiteralText('`', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText('}', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 13: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -23897,15 +24269,15 @@ var ts; } function emitDownlevelRawTemplateLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 10 || node.kind === 13; + var isLast = node.kind === 11 || node.kind === 14; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10) { + if (node.template.kind === 11) { literalEmitter(node.template); } else { @@ -23931,11 +24303,11 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 180) { + if (node.template.kind === 181) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 - && templateSpan.expression.operatorToken.kind === 23; + var needsParens = templateSpan.expression.kind === 179 + && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -23958,7 +24330,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 169 + var needsParens = templateSpan.expression.kind !== 170 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -23991,11 +24363,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165: case 166: - return parent.expression === template; case 167: - case 169: + return parent.expression === template; + case 168: + case 170: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24003,20 +24375,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 178: + case 179: switch (expression.operatorToken.kind) { - case 36: case 37: case 38: + case 39: return 1; - case 34: case 35: + case 36: return 0; default: return -1; } - case 181: - case 179: + case 182: + case 180: return -1; default: return 1; @@ -24029,10 +24401,10 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 66 && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24040,9 +24412,9 @@ var ts; } function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24068,36 +24440,36 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236) { - if (i_2 === 0) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235); + ts.Debug.assert(attrs[i_1].kind === 236); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -24117,15 +24489,15 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 237 && !(children[i].expression)) { + if (children[i].kind === 238 && !(children[i].expression)) { continue; } - if (children[i].kind === 233) { + if (children[i].kind === 234) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -24137,11 +24509,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxElement(node); } } @@ -24161,11 +24533,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236) { + if (attribs[i].kind === 237) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235); + ts.Debug.assert(attribs[i].kind === 236); emitJsxAttribute(attribs[i]); } } @@ -24173,11 +24545,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231)) { + if (node.attributes.length > 0 || (node.kind === 232)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231) { + if (node.kind === 232) { write("/>"); } else { @@ -24196,20 +24568,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160); - if (node.kind === 8) { + ts.Debug.assert(node.kind !== 161); + if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 133) { + else if (node.kind === 134) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -24228,7 +24600,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24240,58 +24612,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161: - case 178: - case 165: - case 238: - case 133: + case 162: case 179: - case 136: - case 172: - case 194: - case 164: - case 224: - case 192: - case 185: - case 196: + case 166: + case 239: + case 134: + case 180: + case 137: + case 173: + case 195: + case 165: + case 225: + case 193: + case 186: case 197: case 198: - case 193: - case 231: + case 199: + case 194: case 232: - case 166: - case 169: - case 177: - case 176: - case 201: - case 243: - case 182: - case 203: + case 233: + case 237: + case 238: case 167: - case 187: - case 205: - case 168: - case 173: - case 174: - case 195: - case 202: - case 181: - return true; - case 160: - case 244: - case 135: - case 242: - case 138: - case 208: - return parent.initializer === node; - case 163: - return parent.expression === node; - case 171: case 170: + case 178: + case 177: + case 202: + case 244: + case 183: + case 204: + case 168: + case 188: + case 206: + case 169: + case 174: + case 175: + case 196: + case 203: + case 182: + return true; + case 161: + case 245: + case 136: + case 243: + case 139: + case 209: + return parent.initializer === node; + case 164: + return parent.expression === node; + case 172: + case 171: return parent.body === node; - case 218: + case 219: return parent.moduleReference === node; - case 132: + case 133: return parent.left === node; } return false; @@ -24303,7 +24677,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245) { + if (container.kind === 246) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -24316,12 +24690,12 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220) { + if (declaration.kind === 221) { write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? '["default"]' : ".default"); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223) { + else if (declaration.kind === 224) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); @@ -24338,13 +24712,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160: - case 211: - case 214: - case 208: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161: + case 212: + case 215: + case 209: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -24418,7 +24792,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24432,7 +24806,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24440,22 +24814,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 && node.parent.condition === node) { + else if (node.parent.kind === 180 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66: - case 161: - case 163: + case 67: + case 162: case 164: case 165: - case 169: + case 166: + case 170: return false; } return true; @@ -24472,17 +24846,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182) { + if (e.kind === 183) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182) { + while (i < length && elements[i].kind !== 183) { i++; } write("["); @@ -24505,7 +24879,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24566,7 +24940,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 || property.kind === 143) { + if (property.kind === 143 || property.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -24617,13 +24991,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242) { + if (property.kind === 243) { emit(property.initializer); } - else if (property.kind === 243) { + else if (property.kind === 244) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140) { + else if (property.kind === 141) { emitFunctionDeclaration(property); } else { @@ -24655,7 +25029,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 === 133) { + if (properties[i].name.kind === 134) { numInitialNonComputedProperties = i; break; } @@ -24669,35 +25043,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178, startsOnNewLine); + var result = ts.createSynthesizedNode(179, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20); + result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(165); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 168 || expr.kind === 186) { + while (expr.kind === 169 || expr.kind === 187) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 && - expr.kind !== 7) { + expr.kind !== 167 && + expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(169); + var node = ts.createSynthesizedNode(170); node.expression = expr; return node; } @@ -24719,11 +25093,12 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245; + return container && container.kind !== 246; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -24733,20 +25108,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 || node.kind === 165 + ? resolver.getConstantValue(node) + : undefined; + } function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); @@ -24769,9 +25149,15 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -24789,7 +25175,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66) { + if (node.left.kind === 67) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -24805,11 +25191,11 @@ var ts; emitEntityNameAsExpression(node.left, false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66: + case 67: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -24817,7 +25203,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -24832,16 +25218,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182; }); + return ts.forEach(elements, function (e) { return e.kind === 183; }); } function skipParentheses(node) { - while (node.kind === 169 || node.kind === 168 || node.kind === 186) { + while (node.kind === 170 || node.kind === 169 || node.kind === 187) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 || node.kind === 94 || node.kind === 92) { + if (node.kind === 67 || node.kind === 95 || node.kind === 93) { emit(node); return node; } @@ -24856,18 +25242,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163) { + if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164) { + else if (expr.kind === 165) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92) { + else if (expr.kind === 93) { target = expr; write("_super"); } @@ -24876,7 +25262,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -24896,13 +25282,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; + superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; } if (superCall && languageVersion < 2) { write(".call("); @@ -24953,20 +25339,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { - if (node.expression.kind === 168 || node.expression.kind === 186) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { + if (node.expression.kind === 169 || node.expression.kind === 187) { var operand = node.expression.expression; - while (operand.kind === 168 || operand.kind === 186) { + while (operand.kind === 169 || operand.kind === 187) { operand = operand.expression; } - if (operand.kind !== 176 && + if (operand.kind !== 177 && + operand.kind !== 175 && operand.kind !== 174 && operand.kind !== 173 && - operand.kind !== 172 && - operand.kind !== 177 && - operand.kind !== 166 && - !(operand.kind === 165 && node.parent.kind === 166) && - !(operand.kind === 170 && node.parent.kind === 165)) { + operand.kind !== 178 && + operand.kind !== 167 && + !(operand.kind === 166 && node.parent.kind === 167) && + !(operand.kind === 171 && node.parent.kind === 166)) { emit(operand); return; } @@ -24977,25 +25363,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75)); + write(ts.tokenToString(76)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25009,12 +25395,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 176) { + if (node.operand.kind === 177) { var operand = node.operand; - if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } - else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { write(" "); } } @@ -25031,7 +25417,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39) { + if (node.operator === 40) { write(") - 1)"); } else { @@ -25052,10 +25438,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245) { + if (current.kind === 246) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216) { + else if (ts.isFunctionLike(current) || current.kind === 217) { return false; } else { @@ -25064,13 +25450,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 54 && - (node.left.kind === 162 || node.left.kind === 161)) { - emitDestructuring(node, node.parent.kind === 192); + if (languageVersion < 2 && node.operatorToken.kind === 55 && + (node.left.kind === 163 || node.left.kind === 162)) { + emitDestructuring(node, node.parent.kind === 193); } else { - var exportChanged = node.operatorToken.kind >= 54 && - node.operatorToken.kind <= 65 && + var exportChanged = node.operatorToken.kind >= 55 && + node.operatorToken.kind <= 66 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -25078,7 +25464,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -25113,36 +25499,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189) { + if (node && node.kind === 190) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14, node.pos); + emitToken(15, node.pos); write(" "); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); return; } - emitToken(14, node.pos); + emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216) { - ts.Debug.assert(node.parent.kind === 215); + if (node.kind === 217) { + ts.Debug.assert(node.parent.kind === 216); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216) { + if (node.kind === 217) { emitTempDeclarations(true); } decreaseIndent(); writeLine(); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189) { + if (node.kind === 190) { write(" "); emit(node); } @@ -25154,20 +25540,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171); + emitParenthesizedIf(node.expression, node.expression.kind === 172); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85, node.pos); + var endPos = emitToken(86, node.pos); write(" "); - endPos = emitToken(16, endPos); + endPos = emitToken(17, endPos); emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77, node.thenStatement.end); - if (node.elseStatement.kind === 193) { + emitToken(78, node.thenStatement.end); + if (node.elseStatement.kind === 194) { write(" "); emit(node.elseStatement); } @@ -25179,7 +25565,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { write(" "); } else { @@ -25199,13 +25585,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 99; + var tokenKind = 100; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 105; + tokenKind = 106; } else if (ts.isConst(decl)) { - tokenKind = 71; + tokenKind = 72; } } if (startPos !== undefined) { @@ -25214,13 +25600,13 @@ var ts; } else { switch (tokenKind) { - case 99: + case 100: write("var "); break; - case 105: + case 106: write("let "); break; - case 71: + case 72: write("const "); break; } @@ -25245,10 +25631,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 210) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -25269,13 +25655,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 198) { + if (languageVersion < 2 && node.kind === 199) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer.kind === 210) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -25285,14 +25671,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197) { + if (node.kind === 198) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -25316,10 +25702,10 @@ var ts; // 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(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 66; + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 67; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -25339,7 +25725,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25347,13 +25733,13 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25362,7 +25748,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25374,17 +25760,17 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); - if (node.initializer.kind === 161 || node.initializer.kind === 162) { + var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); + if (node.initializer.kind === 162 || node.initializer.kind === 163) { emitDestructuring(assignmentExpression, true, undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { emitLines(node.statement.statements); } else { @@ -25396,12 +25782,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 ? 67 : 72, node.pos); + emitToken(node.kind === 201 ? 68 : 73, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91, node.pos); + emitToken(92, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -25412,21 +25798,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93, node.pos); + var endPos = emitToken(94, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.expression); - endPos = emitToken(17, node.expression.end); + endPos = emitToken(18, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14, startPos); + emitToken(15, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15, node.clauses.end); + emitToken(16, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -25441,7 +25827,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238) { + if (node.kind === 239) { write("case "); emit(node.expression); write(":"); @@ -25476,16 +25862,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69, node.pos); + var endPos = emitToken(70, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.variableDeclaration); - emitToken(17, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73, node.pos); + emitToken(74, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -25496,7 +25882,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215); + } while (node && node.kind !== 216); return node; } function emitContainingModuleName(node) { @@ -25515,16 +25901,33 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7); + var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(174); + var result = ts.createSynthesizedNode(175); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); + if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1) { writeLine(); @@ -25535,7 +25938,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25543,6 +25946,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25561,44 +25965,48 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - 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); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 208) { + if (root.kind === 209) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135) { + else if (root.kind === 136) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178) { + if (root.kind === 179) { emitAssignmentExpression(root); } else { @@ -25609,11 +26017,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -25629,7 +26037,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66) { + if (expr.kind !== 67) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -25641,37 +26049,37 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(178); + var equals = ts.createSynthesizedNode(179); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31); + equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179); + var cond = ts.createSynthesizedNode(180); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51); + cond.questionToken = ts.createSynthesizedNode(52); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52); + cond.colonToken = ts.createSynthesizedNode(53); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7); + var node = ts.createSynthesizedNode(8); node.text = "" + value; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66) { + if (syntheticName.kind !== 67) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165); - var sliceIdentifier = ts.createSynthesizedNode(66); + var call = ts.createSynthesizedNode(166); + var sliceIdentifier = ts.createSynthesizedNode(67); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -25685,7 +26093,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -25698,8 +26106,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -25709,14 +26117,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161) { + else if (target.kind === 162) { emitArrayLiteralAssignment(target, value); } else { @@ -25726,18 +26134,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write(")"); } } @@ -25757,11 +26168,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184) { + else if (element.kind !== 185) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -25792,15 +26203,15 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 197 && - node.parent.parent.kind !== 198) { + node.parent.parent.kind !== 198 && + node.parent.parent.kind !== 199) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -25811,11 +26222,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184) { + if (node.kind === 185) { return; } var name = node.name; - if (name.kind === 66) { + if (name.kind === 67) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -25823,7 +26234,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { + if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -25831,7 +26242,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 245; + node.parent.kind === 246; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -25929,9 +26340,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -25950,7 +26361,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -25971,7 +26382,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -25980,26 +26391,26 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 ? "get " : "set "); + write(node.kind === 143 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 && languageVersion >= 2; + return node.kind === 172 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170) { + if (node.kind === 171) { return !!node.name; } - if (node.kind === 210) { + if (node.kind === 211) { return !!node.name || languageVersion < 2; } } @@ -26007,9 +26418,12 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 && node.kind !== 139) { + if (node.kind !== 141 && node.kind !== 140 && + node.parent && node.parent.kind !== 243 && + node.parent.kind !== 166) { emitLeadingComments(node); } + emitStart(node); if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); @@ -26027,10 +26441,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 && node.kind !== 139) { + emitEnd(node); + if (node.kind !== 141 && node.kind !== 140) { emitTrailingComments(node); } } @@ -26062,7 +26477,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171; + var isArrowFunction = node.kind === 172; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26105,7 +26520,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26153,10 +26568,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 168) { + while (current.kind === 169) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162); + emitParenthesizedIf(body, current.kind === 163); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26222,17 +26637,17 @@ var ts; emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15, body.statements.end); + emitToken(16, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192) { + if (statement && statement.kind === 193) { var expr = statement.expression; - if (expr && expr.kind === 165) { + if (expr && expr.kind === 166) { var func = expr.expression; - if (func && func.kind === 92) { + if (func && func.kind === 93) { return statement; } } @@ -26256,24 +26671,24 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 8 || memberName.kind === 7) { + if (memberName.kind === 9 || memberName.kind === 8) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133) { + else if (memberName.kind === 134) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -26313,11 +26728,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188) { + if (member.kind === 189) { writeLine(); write(";"); } - else if (member.kind === 140 || node.kind === 139) { + else if (member.kind === 141 || node.kind === 140) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -26329,14 +26744,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 || member.kind === 143) { + else if (member.kind === 143 || member.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26386,22 +26799,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 || node.kind === 139) && !member.body) { + if ((member.kind === 141 || node.kind === 140) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 || - member.kind === 142 || - member.kind === 143) { + else if (member.kind === 141 || + member.kind === 143 || + member.kind === 144) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 142) { + if (member.kind === 143) { write("get "); } - else if (member.kind === 143) { + else if (member.kind === 144) { write("set "); } if (member.asteriskToken) { @@ -26412,7 +26825,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26433,10 +26846,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 141 && !member.body) { + if (member.kind === 142 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -26467,18 +26880,21 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -26505,7 +26921,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26513,7 +26929,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -26536,7 +26952,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211) { + if (node.kind === 212) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -26553,7 +26969,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -26580,7 +26996,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -26620,7 +27036,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -26658,7 +27074,7 @@ var ts; writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15, node.members.end, function () { + emitToken(16, node.members.end, function () { write("return "); emitDeclarationName(node); }); @@ -26670,7 +27086,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -26678,11 +27094,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211) { + if (node.kind === 212) { write(";"); } emitEnd(node); - if (node.kind === 211) { + if (node.kind === 212) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -26756,13 +27172,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 140) { + if (member.kind === 141) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 138) { + if (member.kind !== 139) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -26792,7 +27208,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138) { + if (member.kind !== 139) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -26831,45 +27247,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 140: - case 142: + case 141: case 143: - case 138: + case 144: + case 139: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 140: + case 141: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 211: - case 140: - case 143: + case 212: + case 141: + case 144: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 211: + case 212: write("Function"); return; - case 138: + case 139: emitSerializedTypeNode(node.type); return; - case 135: - emitSerializedTypeNode(node.type); - return; - case 142: + case 136: emitSerializedTypeNode(node.type); return; case 143: + emitSerializedTypeNode(node.type); + return; + case 144: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -26880,43 +27296,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100: + case 101: write("void 0"); return; - case 157: + case 158: emitSerializedTypeNode(node.type); return; - case 149: case 150: + case 151: write("Function"); return; - case 153: case 154: + case 155: write("Array"); return; - case 147: - case 117: + case 148: + case 118: write("Boolean"); return; - case 127: - case 8: + case 128: + case 9: write("String"); return; - case 125: + case 126: write("Number"); return; - case 128: + case 129: write("Symbol"); return; - case 148: + case 149: emitSerializedTypeReferenceNode(node); return; - case 151: case 152: - case 155: + case 153: case 156: - case 114: + case 157: + case 115: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -26925,8 +27344,13 @@ var ts; write("Object"); } function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0); @@ -26975,7 +27399,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 211) { + if (node.kind === 212) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -26991,10 +27415,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153) { + if (parameterType.kind === 154) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27011,7 +27435,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27088,7 +27512,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27147,7 +27571,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215) { + if (moduleDeclaration.body.kind === 216) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27182,7 +27606,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216) { + if (node.body.kind === 217) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27201,7 +27625,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27214,7 +27638,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -27226,29 +27650,41 @@ var ts; emitExportMemberAssignments(node.name); } } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8) { + if (moduleName.kind === 9) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 && node.importClause && !!node.importClause.name; + return node.kind === 220 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27275,7 +27711,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27301,7 +27737,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -27313,7 +27749,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27359,16 +27795,29 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } } - else if (!(node.flags & 1)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -27396,11 +27845,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -27422,7 +27871,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27434,10 +27882,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27450,13 +27897,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -27469,8 +27914,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 && - expression.kind !== 211) { + if (expression.kind !== 211 && + expression.kind !== 212) { write(";"); } emitEnd(node); @@ -27484,6 +27929,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27506,18 +27952,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219: + case 220: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 218: - if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { + case 219: + if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 225: + case 226: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -27535,7 +27981,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27560,17 +28006,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 && node.importClause) { + if (node.kind === 220 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 && node.moduleSpecifier) { + if (node.kind === 226 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - return getLiteralText(moduleName); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -27582,8 +28028,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 225 || - (importNode.kind === 219 && !importNode.importClause); + var skipNode = importNode.kind === 226 || + (importNode.kind === 220 && !importNode.importClause); if (skipNode) { continue; } @@ -27608,7 +28054,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 && externalImport.exportClause) { + if (externalImport.kind === 226 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -27637,7 +28083,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225) { + if (externalImport.kind !== 226) { continue; } var exportDecl = externalImport; @@ -27659,6 +28105,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -27666,17 +28114,19 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 66 && node.flags & 1024) { + if (node.kind !== 67 && node.flags & 1024) { return; } if (started) { @@ -27687,8 +28137,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -27707,7 +28157,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 + var name_25 = local.kind === 67 ? local : local.name; if (name_25) { @@ -27722,13 +28172,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 || local.kind === 215 || local.kind === 214) { + if (local.kind === 212 || local.kind === 216 || local.kind === 215) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -27756,21 +28206,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 210) { + if (node.kind === 211) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211) { + if (node.kind === 212) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214) { + if (node.kind === 215) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -27779,7 +28229,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -27788,10 +28238,10 @@ var ts; } return; } - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { if (shouldHoistVariable(node, false)) { var name_26 = node.name; - if (name_26.kind === 66) { + if (name_26.kind === 67) { if (!hoistedVars) { hoistedVars = []; } @@ -27803,6 +28253,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -27817,12 +28274,12 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245; + ts.getEnclosingBlockScopeContainer(node).kind === 246; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); writeLine(); var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); @@ -27831,7 +28288,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -27839,75 +28296,64 @@ var ts; write("}"); emitTempDeclarations(true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219: - if (!importNode.importClause) { - break; - } - case 218: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220: + if (!entry.importClause) { + break; + } + case 219: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221) { - emitExportMemberAssignments(namedBindings.name); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } 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 225: - 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("\"]);"); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -27920,14 +28366,25 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 225: - case 219: - case 218: - case 210: + case 211: + case 220: continue; + case 226: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -27943,8 +28400,19 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -27953,8 +28421,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -28012,6 +28481,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28031,6 +28501,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28039,6 +28510,7 @@ var ts; emitExportEquals(false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); emitAMDDependencies(node, false); @@ -28058,6 +28530,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28083,7 +28556,7 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; var text = ts.getTextOfNode(node); var firstNonWhitespace = 0; @@ -28093,7 +28566,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -28106,15 +28579,25 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -28128,13 +28611,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -28143,9 +28626,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28177,10 +28660,7 @@ var ts; } } } - function emitSourceFileNode(node) { - writeLine(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLines(extendsHelper); @@ -28202,6 +28682,12 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); @@ -28224,47 +28710,63 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 213: + case 211: + case 220: + case 219: + case 214: + case 225: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 212: - case 210: - case 219: - case 218: - case 213: - case 224: - return false; - case 190: + case 191: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215: + case 216: return shouldEmitModuleDeclaration(node); - case 214: + case 215: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 189 && + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 190 && node.parent && - node.parent.kind === 171 && + node.parent.kind === 172 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -28273,170 +28775,170 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 66: + case 67: return emitIdentifier(node); - case 135: + case 136: return emitParameter(node); + case 141: case 140: - case 139: return emitMethod(node); - case 142: case 143: + case 144: return emitAccessor(node); - case 94: + case 95: return emitThis(node); - case 92: + case 93: return emitSuper(node); - case 90: + case 91: return write("null"); - case 96: + case 97: return write("true"); - case 81: + case 82: return write("false"); - case 7: case 8: case 9: case 10: case 11: case 12: case 13: + case 14: return emitLiteral(node); - case 180: - return emitTemplateExpression(node); - case 187: - return emitTemplateSpan(node); - case 230: - case 231: - return emitJsxElement(node); - case 233: - return emitJsxText(node); - case 237: - return emitJsxExpression(node); - case 132: - return emitQualifiedName(node); - case 158: - return emitObjectBindingPattern(node); - case 159: - return emitArrayBindingPattern(node); - case 160: - return emitBindingElement(node); - case 161: - return emitArrayLiteral(node); - case 162: - return emitObjectLiteral(node); - case 242: - return emitPropertyAssignment(node); - case 243: - return emitShorthandPropertyAssignment(node); - case 133: - return emitComputedPropertyName(node); - case 163: - return emitPropertyAccess(node); - case 164: - return emitIndexedAccess(node); - case 165: - return emitCallExpression(node); - case 166: - return emitNewExpression(node); - case 167: - return emitTaggedTemplateExpression(node); - case 168: - return emit(node.expression); - case 186: - return emit(node.expression); - case 169: - return emitParenExpression(node); - case 210: - case 170: - case 171: - return emitFunctionDeclaration(node); - case 172: - return emitDeleteExpression(node); - case 173: - return emitTypeOfExpression(node); - case 174: - return emitVoidExpression(node); - case 175: - return emitAwaitExpression(node); - case 176: - return emitPrefixUnaryExpression(node); - case 177: - return emitPostfixUnaryExpression(node); - case 178: - return emitBinaryExpression(node); - case 179: - return emitConditionalExpression(node); - case 182: - return emitSpreadElementExpression(node); case 181: - return emitYieldExpression(node); - case 184: - return; - case 189: - case 216: - return emitBlock(node); - case 190: - return emitVariableStatement(node); - case 191: - return write(";"); - case 192: - return emitExpressionStatement(node); - case 193: - return emitIfStatement(node); - case 194: - return emitDoStatement(node); - case 195: - return emitWhileStatement(node); - case 196: - return emitForStatement(node); - case 198: - case 197: - return emitForInOrForOfStatement(node); - case 199: - case 200: - return emitBreakOrContinueStatement(node); - case 201: - return emitReturnStatement(node); - case 202: - return emitWithStatement(node); - case 203: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 188: + return emitTemplateSpan(node); + case 231: + case 232: + return emitJsxElement(node); + case 234: + return emitJsxText(node); case 238: - case 239: - return emitCaseOrDefaultClause(node); - case 204: - return emitLabelledStatement(node); - case 205: - return emitThrowStatement(node); - case 206: - return emitTryStatement(node); - case 241: - return emitCatchClause(node); - case 207: - return emitDebuggerStatement(node); - case 208: - return emitVariableDeclaration(node); - case 183: - return emitClassExpression(node); - case 211: - return emitClassDeclaration(node); - case 212: - return emitInterfaceDeclaration(node); - case 214: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 133: + return emitQualifiedName(node); + case 159: + return emitObjectBindingPattern(node); + case 160: + return emitArrayBindingPattern(node); + case 161: + return emitBindingElement(node); + case 162: + return emitArrayLiteral(node); + case 163: + return emitObjectLiteral(node); + case 243: + return emitPropertyAssignment(node); case 244: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 134: + return emitComputedPropertyName(node); + case 164: + return emitPropertyAccess(node); + case 165: + return emitIndexedAccess(node); + case 166: + return emitCallExpression(node); + case 167: + return emitNewExpression(node); + case 168: + return emitTaggedTemplateExpression(node); + case 169: + return emit(node.expression); + case 187: + return emit(node.expression); + case 170: + return emitParenExpression(node); + case 211: + case 171: + case 172: + return emitFunctionDeclaration(node); + case 173: + return emitDeleteExpression(node); + case 174: + return emitTypeOfExpression(node); + case 175: + return emitVoidExpression(node); + case 176: + return emitAwaitExpression(node); + case 177: + return emitPrefixUnaryExpression(node); + case 178: + return emitPostfixUnaryExpression(node); + case 179: + return emitBinaryExpression(node); + case 180: + return emitConditionalExpression(node); + case 183: + return emitSpreadElementExpression(node); + case 182: + return emitYieldExpression(node); + case 185: + return; + case 190: + case 217: + return emitBlock(node); + case 191: + return emitVariableStatement(node); + case 192: + return write(";"); + case 193: + return emitExpressionStatement(node); + case 194: + return emitIfStatement(node); + case 195: + return emitDoStatement(node); + case 196: + return emitWhileStatement(node); + case 197: + return emitForStatement(node); + case 199: + case 198: + return emitForInOrForOfStatement(node); + case 200: + case 201: + return emitBreakOrContinueStatement(node); + case 202: + return emitReturnStatement(node); + case 203: + return emitWithStatement(node); + case 204: + return emitSwitchStatement(node); + case 239: + case 240: + return emitCaseOrDefaultClause(node); + case 205: + return emitLabelledStatement(node); + case 206: + return emitThrowStatement(node); + case 207: + return emitTryStatement(node); + case 242: + return emitCatchClause(node); + case 208: + return emitDebuggerStatement(node); + case 209: + return emitVariableDeclaration(node); + case 184: + return emitClassExpression(node); + case 212: + return emitClassDeclaration(node); + case 213: + return emitInterfaceDeclaration(node); case 215: - return emitModuleDeclaration(node); - case 219: - return emitImportDeclaration(node); - case 218: - return emitImportEqualsDeclaration(node); - case 225: - return emitExportDeclaration(node); - case 224: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 245: + return emitEnumMember(node); + case 216: + return emitModuleDeclaration(node); + case 220: + return emitImportDeclaration(node); + case 219: + return emitImportEqualsDeclaration(node); + case 226: + return emitExportDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFileNode(node); } } @@ -28464,7 +28966,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -28476,7 +28978,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.end !== node.parent.end) { + if (node.parent.kind === 246 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -28496,6 +28998,10 @@ var ts; var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { @@ -28541,6 +29047,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; @@ -28561,6 +29073,261 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// @@ -28570,7 +29337,8 @@ var ts; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -28587,6 +29355,49 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + return legacyNameResolver(moduleName, containingFile, compilerOptions, host); + } + ts.resolveModuleName = resolveModuleName; + function legacyNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -28649,7 +29460,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -28684,7 +29497,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -28695,14 +29508,30 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -28734,6 +29563,58 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -28760,7 +29641,7 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -28841,14 +29722,51 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220: + case 219: + case 226: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -28879,15 +29797,15 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); @@ -28899,8 +29817,8 @@ var ts; return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -28910,11 +29828,11 @@ var ts; if (file) { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -28930,7 +29848,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -28938,49 +29861,30 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 || node.kind === 218 || node.kind === 225) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 && 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) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -29032,28 +29936,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -29061,16 +29965,20 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } 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)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2) { @@ -29092,7 +30000,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); } @@ -29104,16 +30012,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2) { @@ -29244,6 +30158,12 @@ var ts; { name: "out", type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -29446,7 +30366,7 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -29519,6 +30439,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -29553,7 +30476,7 @@ var ts; function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, 'en', 'ja-jp')); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); return false; } var language = matchResult[1]; @@ -29576,7 +30499,7 @@ var ts; if (!ts.sys.fileExists(filePath)) { return false; } - var fileContents = ''; + var fileContents = ""; try { fileContents = ts.sys.readFile(filePath); } @@ -29823,16 +30746,15 @@ var ts; } return { program: program, exitStatus: exitStatus }; function compileProgram() { - var diagnostics = program.getSyntacticDiagnostics(); - reportDiagnostics(diagnostics); + var diagnostics; + diagnostics = program.getSyntacticDiagnostics(); if (diagnostics.length === 0) { - var diagnostics_1 = program.getGlobalDiagnostics(); - reportDiagnostics(diagnostics_1); - if (diagnostics_1.length === 0) { - var diagnostics_2 = program.getSemanticDiagnostics(); - reportDiagnostics(diagnostics_2); + diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + if (diagnostics.length === 0) { + diagnostics = program.getSemanticDiagnostics(); } } + reportDiagnostics(diagnostics); if (compilerOptions.noEmit) { return diagnostics.length ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped diff --git a/lib/tsserver.js b/lib/tsserver.js index 9d582485e2f..6fdd0b20f39 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -57,6 +57,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -78,6 +79,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; function forEach(array, callback) { @@ -495,7 +499,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -649,7 +653,7 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -864,7 +868,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -892,7 +896,7 @@ var ts; } function writeFile(fileName, data, writeByteOrderMark) { if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -933,7 +937,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -955,7 +959,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -992,7 +995,7 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { return getNodeSystem(); } else { @@ -1255,6 +1258,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -1294,7 +1298,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -1425,6 +1429,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, 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}'." }, @@ -1504,20 +1510,11 @@ var ts; 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}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_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 'isolatedModules' 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." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, 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." }, @@ -1568,7 +1565,6 @@ var ts; 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'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, @@ -1613,7 +1609,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -1621,123 +1618,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112, - "any": 114, - "as": 113, - "boolean": 117, - "break": 67, - "case": 68, - "catch": 69, - "class": 70, - "continue": 72, - "const": 71, - "constructor": 118, - "debugger": 73, - "declare": 119, - "default": 74, - "delete": 75, - "do": 76, - "else": 77, - "enum": 78, - "export": 79, - "extends": 80, - "false": 81, - "finally": 82, - "for": 83, - "from": 130, - "function": 84, - "get": 120, - "if": 85, - "implements": 103, - "import": 86, - "in": 87, - "instanceof": 88, - "interface": 104, - "is": 121, - "let": 105, - "module": 122, - "namespace": 123, - "new": 89, - "null": 90, - "number": 125, - "package": 106, - "private": 107, - "protected": 108, - "public": 109, - "require": 124, - "return": 91, - "set": 126, - "static": 110, - "string": 127, - "super": 92, - "switch": 93, - "symbol": 128, - "this": 94, - "throw": 95, - "true": 96, - "try": 97, - "type": 129, - "typeof": 98, - "var": 99, - "void": 100, - "while": 101, - "with": 102, - "yield": 111, - "async": 115, - "await": 116, - "of": 131, - "{": 14, - "}": 15, - "(": 16, - ")": 17, - "[": 18, - "]": 19, - ".": 20, - "...": 21, - ";": 22, - ",": 23, - "<": 24, - ">": 26, - "<=": 27, - ">=": 28, - "==": 29, - "!=": 30, - "===": 31, - "!==": 32, - "=>": 33, - "+": 34, - "-": 35, - "*": 36, - "/": 37, - "%": 38, - "++": 39, - "--": 40, - "<<": 41, - ">": 42, - ">>>": 43, - "&": 44, - "|": 45, - "^": 46, - "!": 47, - "~": 48, - "&&": 49, - "||": 50, - "?": 51, - ":": 52, - "=": 54, - "+=": 55, - "-=": 56, - "*=": 57, - "/=": 58, - "%=": 59, - "<<=": 60, - ">>=": 61, - ">>>=": 62, - "&=": 63, - "|=": 64, - "^=": 65, - "@": 53 + "abstract": 113, + "any": 115, + "as": 114, + "boolean": 118, + "break": 68, + "case": 69, + "catch": 70, + "class": 71, + "continue": 73, + "const": 72, + "constructor": 119, + "debugger": 74, + "declare": 120, + "default": 75, + "delete": 76, + "do": 77, + "else": 78, + "enum": 79, + "export": 80, + "extends": 81, + "false": 82, + "finally": 83, + "for": 84, + "from": 131, + "function": 85, + "get": 121, + "if": 86, + "implements": 104, + "import": 87, + "in": 88, + "instanceof": 89, + "interface": 105, + "is": 122, + "let": 106, + "module": 123, + "namespace": 124, + "new": 90, + "null": 91, + "number": 126, + "package": 107, + "private": 108, + "protected": 109, + "public": 110, + "require": 125, + "return": 92, + "set": 127, + "static": 111, + "string": 128, + "super": 93, + "switch": 94, + "symbol": 129, + "this": 95, + "throw": 96, + "true": 97, + "try": 98, + "type": 130, + "typeof": 99, + "var": 100, + "void": 101, + "while": 102, + "with": 103, + "yield": 112, + "async": 116, + "await": 117, + "of": 132, + "{": 15, + "}": 16, + "(": 17, + ")": 18, + "[": 19, + "]": 20, + ".": 21, + "...": 22, + ";": 23, + ",": 24, + "<": 25, + ">": 27, + "<=": 28, + ">=": 29, + "==": 30, + "!=": 31, + "===": 32, + "!==": 33, + "=>": 34, + "+": 35, + "-": 36, + "*": 37, + "/": 38, + "%": 39, + "++": 40, + "--": 41, + "<<": 42, + ">": 43, + ">>>": 44, + "&": 45, + "|": 46, + "^": 47, + "!": 48, + "~": 49, + "&&": 50, + "||": 51, + "?": 52, + ":": 53, + "=": 55, + "+=": 56, + "-=": 57, + "*=": 58, + "/=": 59, + "%=": 60, + "<<=": 61, + ">>=": 62, + ">>>=": 63, + "&=": 64, + "|=": 65, + "^=": 66, + "@": 54 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1838,6 +1835,7 @@ var ts; var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -1903,6 +1901,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1959,12 @@ var ts; continue; } break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2010,6 +2016,16 @@ var ts; } return pos; } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -2091,6 +2107,12 @@ var ts; return getCommentRanges(text, pos, true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 36 || ch === 95 || @@ -2124,8 +2146,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 || token > 102; }, - isReservedWord: function () { return token >= 67 && token <= 102; }, + isIdentifier: function () { return token === 67 || token > 103; }, + isReservedWord: function () { return token >= 68 && token <= 103; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2265,20 +2287,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 : 12; + resultingToken = startedWithBacktick ? 12 : 13; break; } if (currChar === 92) { @@ -2439,7 +2461,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66; + return token = 67; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2471,6 +2493,15 @@ var ts; return token = 1; } var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } switch (ch) { case 10: case 13: @@ -2505,66 +2536,66 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } - return pos++, token = 47; + return pos++, token = 48; case 34: case 39: tokenValue = scanString(); - return token = 8; + return token = 9; case 96: return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } - return pos++, token = 38; + return pos++, token = 39; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 40: - return pos++, token = 16; - case 41: return pos++, token = 17; + case 41: + return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 39; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; - } - return pos++, token = 34; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 40; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 56; } return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 36; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 21; + return pos += 3, token = 22; } - return pos++, token = 20; + return pos++, token = 21; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -2608,9 +2639,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2620,7 +2651,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; @@ -2630,7 +2661,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; @@ -2640,11 +2671,11 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7; + return token = 8; } case 49: case 50: @@ -2656,11 +2687,11 @@ var ts; case 56: case 57: tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; case 58: - return pos++, token = 52; + return pos++, token = 53; case 59: - return pos++, token = 22; + return pos++, token = 23; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2668,22 +2699,22 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 27; + return pos += 2, token = 28; } if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { - return pos += 2, token = 25; + return pos += 2, token = 26; } - return pos++, token = 24; + return pos++, token = 25; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2691,19 +2722,19 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 33; + return pos += 2, token = 34; } - return pos++, token = 54; + return pos++, token = 55; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2711,37 +2742,37 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } - return pos++, token = 26; + return pos++, token = 27; case 63: - return pos++, token = 51; + return pos++, token = 52; case 91: - return pos++, token = 18; - case 93: return pos++, token = 19; + case 93: + return pos++, token = 20; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 66; + } + return pos++, token = 47; + case 123: + return pos++, token = 15; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 51; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 65; } return pos++, token = 46; - case 123: - return pos++, token = 14; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 50; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - return pos++, token = 45; case 125: - return pos++, token = 15; + return pos++, token = 16; case 126: - return pos++, token = 48; + return pos++, token = 49; case 64: - return pos++, token = 53; + return pos++, token = 54; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2777,27 +2808,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26) { + if (token === 27) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 62; + return pos += 3, token = 63; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } - return pos++, token = 42; + return pos++, token = 43; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 28; + return pos++, token = 29; } } return token; } function reScanSlashToken() { - if (token === 37 || token === 58) { + if (token === 38 || token === 59) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2836,12 +2867,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9; + token = 10; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 15, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -2858,14 +2889,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 25; + return token = 26; } pos++; - return token = 24; + return token = 25; } if (char === 123) { pos++; - return token = 14; + return token = 15; } while (pos < end) { pos++; @@ -2874,10 +2905,10 @@ var ts; break; } } - return token = 233; + return token = 234; } function scanJsxIdentifier() { - if (token === 66) { + if (token === 67) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -3065,6 +3096,12 @@ var ts; { name: "out", type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -3267,7 +3304,7 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -3340,6 +3377,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -3416,6 +3456,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; function containsParseError(node) { aggregateChildData(node); return (node.parserContextFlags & 64) !== 0; @@ -3432,7 +3503,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3508,7 +3579,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -3523,15 +3594,15 @@ var ts; return current; } switch (current.kind) { - case 245: - case 217: - case 241: - case 215: - case 196: + case 246: + case 218: + case 242: + case 216: case 197: case 198: + case 199: return current; - case 189: + case 190: if (!isFunctionLike(current.parent)) { return current; } @@ -3542,9 +3613,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 && + declaration.kind === 209 && declaration.parent && - declaration.parent.kind === 241; + declaration.parent.kind === 242; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3580,22 +3651,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245: + case 246: 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 208: - case 160: - case 211: - case 183: + case 209: + case 161: case 212: + case 184: + case 213: + case 216: case 215: - case 214: - case 244: - case 210: - case 170: + case 245: + case 211: + case 171: errorNode = node.name; break; } @@ -3617,11 +3688,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 && isConst(node); + return node.kind === 215 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 || isBindingPattern(node))) { + while (node && (node.kind === 161 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3629,14 +3700,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208) { + if (node.kind === 209) { node = node.parent; } - if (node && node.kind === 209) { + if (node && node.kind === 210) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190) { + if (node && node.kind === 191) { flags |= node.flags; } return flags; @@ -3651,20 +3722,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 && node.expression.kind === 8; + return node.kind === 193 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 135 || node.kind === 134) { - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 || node.kind === 135) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && @@ -3674,68 +3743,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 <= node.kind && node.kind <= 157) { + if (149 <= node.kind && node.kind <= 158) { return true; } switch (node.kind) { - case 114: - case 125: - case 127: - case 117: + case 115: + case 126: case 128: + case 118: + case 129: return true; - case 100: - return node.parent.kind !== 174; - case 8: - return node.parent.kind === 135; - case 185: + case 101: + return node.parent.kind !== 175; + case 9: + return node.parent.kind === 136; + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 66: - if (node.parent.kind === 132 && node.parent.right === node) { + case 67: + if (node.parent.kind === 133 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 && node.parent.name === node) { + else if (node.parent.kind === 164 && node.parent.name === node) { node = node.parent; } - case 132: - case 163: - ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 133: + case 164: + ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151) { + if (parent_1.kind === 152) { return false; } - if (148 <= parent_1.kind && parent_1.kind <= 157) { + if (149 <= parent_1.kind && parent_1.kind <= 158) { return true; } switch (parent_1.kind) { - case 185: + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134: - return node === parent_1.constraint; - case 138: - case 137: case 135: - case 208: + return node === parent_1.constraint; + case 139: + case 138: + case 136: + case 209: return node === parent_1.type; - case 210: - case 170: + case 211: case 171: + case 172: + case 142: case 141: case 140: - case 139: - case 142: case 143: - return node === parent_1.type; case 144: + return node === parent_1.type; case 145: case 146: + case 147: return node === parent_1.type; - case 168: + case 169: return node === parent_1.type; - case 165: case 166: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 167: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 168: return false; } } @@ -3746,23 +3815,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201: + case 202: return visitor(node); - case 217: - case 189: - case 193: + case 218: + case 190: case 194: case 195: case 196: case 197: case 198: - case 202: + case 199: case 203: - case 238: - case 239: case 204: - case 206: - case 241: + case 239: + case 240: + case 205: + case 207: + case 242: return ts.forEachChild(node, traverse); } } @@ -3772,23 +3841,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181: + case 182: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214: - case 212: case 215: case 213: - case 211: - case 183: + case 216: + case 214: + case 212: + case 184: return; default: if (isFunctionLike(node)) { var name_6 = node.name; - if (name_6 && name_6.kind === 133) { + if (name_6 && name_6.kind === 134) { traverse(name_6.expression); return; } @@ -3803,14 +3872,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160: - case 244: - case 135: - case 242: - case 138: - case 137: + case 161: + case 245: + case 136: case 243: - case 208: + case 139: + case 138: + case 244: + case 209: return true; } } @@ -3818,41 +3887,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 || node.kind === 143); + return node && (node.kind === 143 || node.kind === 144); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 || node.kind === 183); + return node && (node.kind === 212 || node.kind === 184); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141: - case 170: - case 210: - case 171: - case 140: - case 139: case 142: + case 171: + case 211: + case 172: + case 141: + case 140: case 143: case 144: case 145: case 146: - case 149: + case 147: case 150: + case 151: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141: + case 140: + case 142: + case 143: + case 144: + case 211: + case 171: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 && isFunctionLike(node.parent); + return node && node.kind === 190 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 && node.parent.kind === 162; + return node && node.kind === 141 && node.parent.kind === 163; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3880,36 +3963,36 @@ var ts; return undefined; } switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 171: + case 172: if (!includeArrowFunctions) { continue; } - case 210: - case 170: - case 215: - case 138: - case 137: - case 140: + case 211: + case 171: + case 216: case 139: + case 138: case 141: + case 140: case 142: case 143: - case 214: - case 245: + case 144: + case 215: + case 246: return node; } } @@ -3921,33 +4004,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 210: - case 170: + case 211: case 171: + case 172: if (!includeFunctions) { continue; } - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: return node; } } @@ -3956,12 +4039,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148: + case 149: return node.typeName; - case 185: + case 186: return node.expression; - case 66: - case 132: + case 67: + case 133: return node; } } @@ -3969,7 +4052,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167) { + if (node.kind === 168) { return node.tag; } return node.expression; @@ -3977,40 +4060,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211: + case 212: return true; - case 138: - return node.parent.kind === 211; - case 135: - return node.parent.body && node.parent.parent.kind === 211; - case 142: + case 139: + return node.parent.kind === 212; + case 136: + return node.parent.body && node.parent.parent.kind === 212; case 143: - case 140: - return node.body && node.parent.kind === 211; + case 144: + case 141: + return node.body && node.parent.kind === 212; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211: + case 212: if (node.decorators) { return true; } return false; - case 138: - case 135: + case 139: + case 136: if (node.decorators) { return true; } return false; - case 142: + case 143: if (node.body && node.decorators) { return true; } return false; - case 140: - case 143: + case 141: + case 144: if (node.body && node.decorators) { return true; } @@ -4021,10 +4104,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211: + case 212: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140: - case 143: + case 141: + case 144: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4036,92 +4119,92 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 9: - case 161: + case 95: + case 93: + case 91: + case 97: + case 82: + case 10: case 162: case 163: case 164: case 165: case 166: case 167: - case 186: case 168: + case 187: case 169: case 170: - case 183: case 171: - case 174: + case 184: case 172: + case 175: case 173: - case 176: + case 174: case 177: case 178: case 179: - case 182: case 180: - case 10: - case 184: - case 230: - case 231: + case 183: case 181: + case 11: + case 185: + case 231: + case 232: + case 182: return true; - case 132: - while (node.parent.kind === 132) { + case 133: + while (node.parent.kind === 133) { node = node.parent; } - return node.parent.kind === 151; - case 66: - if (node.parent.kind === 151) { + return node.parent.kind === 152; + case 67: + if (node.parent.kind === 152) { return true; } - case 7: case 8: + case 9: var parent_2 = node.parent; switch (parent_2.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 244: - case 242: - case 160: + case 245: + case 243: + case 161: return parent_2.initializer === node; - case 192: case 193: case 194: case 195: - case 201: + case 196: case 202: case 203: - case 238: - case 205: - case 203: + case 204: + case 239: + case 206: + case 204: return parent_2.expression === node; - case 196: + case 197: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || forStatement.condition === node || forStatement.incrementor === node; - case 197: case 198: + case 199: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || forInStatement.expression === node; - case 168: - case 186: - return node === parent_2.expression; + case 169: case 187: return node === parent_2.expression; - case 133: + case 188: return node === parent_2.expression; - case 136: + case 134: + return node === parent_2.expression; + case 137: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4139,7 +4222,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind === 229; + return node.kind === 219 && node.moduleReference.kind === 230; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4148,20 +4231,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind !== 229; + return node.kind === 219 && node.moduleReference.kind !== 230; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219) { + if (node.kind === 220) { return node.moduleSpecifier; } - if (node.kind === 218) { + if (node.kind === 219) { var reference = node.moduleReference; - if (reference.kind === 229) { + if (reference.kind === 230) { return reference.expression; } } - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } } @@ -4169,15 +4252,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135: - return node.questionToken !== undefined; + case 136: + case 141: case 140: - case 139: - return node.questionToken !== undefined; + case 244: case 243: - case 242: + case 139: case 138: - case 137: return node.questionToken !== undefined; } } @@ -4185,9 +4266,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 && + return node.kind === 259 && node.parameters.length > 0 && - node.parameters[0].type.kind === 260; + node.parameters[0].type.kind === 261; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4201,24 +4282,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 267); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265); + return getJSDocTag(node, 266); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 268); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66) { + if (parameter.name && parameter.name.kind === 67) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264) { + if (t.kind === 265) { var parameterTag = t; var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_7.text === parameterName) { @@ -4237,12 +4318,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 259) { + if (node.type && node.type.kind === 260) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259; + return paramTag.typeExpression.type.kind === 260; } } return node.dotDotDotToken !== undefined; @@ -4251,19 +4332,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 <= kind && kind <= 10; + return 8 <= kind && kind <= 11; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 || kind === 10; + return kind === 9 || kind === 11; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 <= kind && kind <= 13; + return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 || node.kind === 158); + return !!node && (node.kind === 160 || node.kind === 159); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4278,34 +4359,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171: - case 160: - case 211: - case 183: - case 141: - case 214: - case 244: - case 227: - case 210: - case 170: - case 142: - case 220: - case 218: - case 223: + case 172: + case 161: case 212: - case 140: - case 139: + case 184: + case 142: case 215: - case 221: - case 135: - case 242: - case 138: - case 137: + case 245: + case 228: + case 211: + case 171: case 143: - case 243: + case 221: + case 219: + case 224: case 213: - case 134: - case 208: + case 141: + case 140: + case 216: + case 222: + case 136: + case 243: + case 139: + case 138: + case 144: + case 244: + case 214: + case 135: + case 209: return true; } return false; @@ -4313,25 +4394,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200: - case 199: - case 207: - case 194: - case 192: - case 191: - case 197: - case 198: - case 196: - case 193: - case 204: case 201: - case 203: - case 95: - case 206: - case 190: + case 200: + case 208: case 195: + case 193: + case 192: + case 198: + case 199: + case 197: + case 194: + case 205: case 202: - case 224: + case 204: + case 96: + case 207: + case 191: + case 196: + case 203: + case 225: return true; default: return false; @@ -4340,13 +4421,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141: - case 138: - case 140: case 142: - case 143: case 139: - case 146: + case 141: + case 143: + case 144: + case 140: + case 147: return true; default: return false; @@ -4354,11 +4435,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 223 || parent.kind === 227) { + if (parent.kind === 224 || parent.kind === 228) { if (parent.propertyName) { return true; } @@ -4372,54 +4453,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138: - case 137: - case 140: case 139: - case 142: + case 138: + case 141: + case 140: case 143: - case 244: - case 242: - case 163: + case 144: + case 245: + case 243: + case 164: return parent.name === node; - case 132: + case 133: if (parent.right === node) { - while (parent.kind === 132) { + while (parent.kind === 133) { parent = parent.parent; } - return parent.kind === 151; + return parent.kind === 152; } return false; - case 160: - case 223: + case 161: + case 224: return parent.propertyName === node; - case 227: + case 228: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 218 || - node.kind === 220 && !!node.name || - node.kind === 221 || - node.kind === 223 || - node.kind === 227 || - node.kind === 224 && node.expression.kind === 66; + return node.kind === 219 || + node.kind === 221 && !!node.name || + node.kind === 222 || + node.kind === 224 || + node.kind === 228 || + node.kind === 225 && node.expression.kind === 67; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103); + var heritageClause = getHeritageClause(node.heritageClauses, 104); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4488,11 +4569,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 <= token && token <= 131; + return 68 <= token && token <= 132; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 <= token && token <= 6; + return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -4501,19 +4582,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 && + declaration.name.kind === 134 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 && isESSymbolIdentifier(node.expression); + return node.kind === 164 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 || name.kind === 8 || name.kind === 7) { + if (name.kind === 67 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 133) { + if (name.kind === 134) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4528,21 +4609,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 66 && node.text === "Symbol"; + return node.kind === 67 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112: - case 115: - case 71: - case 119: - case 74: - case 79: - case 109: - case 107: - case 108: + case 113: + case 116: + case 72: + case 120: + case 75: + case 80: case 110: + case 108: + case 109: + case 111: return true; } return false; @@ -4550,20 +4631,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135; + return root.kind === 136; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 || n.kind === 245; + return isFunctionLike(n) || n.kind === 216 || n.kind === 246; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67) { + var clone_1 = createSynthesizedNode(67); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -4788,7 +4885,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 && nodeIsPresent(member.body)) { + if (member.kind === 142 && nodeIsPresent(member.body)) { return member; } }); @@ -4800,7 +4897,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; @@ -4815,10 +4912,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142) { + if (accessor.kind === 143) { getAccessor = accessor; } - else if (accessor.kind === 143) { + else if (accessor.kind === 144) { setAccessor = accessor; } else { @@ -4827,7 +4924,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 || member.kind === 143) + if ((member.kind === 143 || member.kind === 144) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4838,10 +4935,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 && !getAccessor) { + if (member.kind === 143 && !getAccessor) { getAccessor = member; } - if (member.kind === 143 && !setAccessor) { + if (member.kind === 144 && !setAccessor) { setAccessor = member; } } @@ -4920,7 +5017,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { writer.write(currentLineText); if (end !== comment.end) { @@ -4947,16 +5044,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110: return 128; - case 109: return 16; - case 108: return 64; - case 107: return 32; - case 112: return 256; - case 79: return 1; - case 119: return 2; - case 71: return 32768; - case 74: return 1024; - case 115: return 512; + case 111: return 128; + case 110: return 16; + case 109: return 64; + case 108: return 32; + case 113: return 256; + case 80: return 1; + case 120: return 2; + case 72: return 32768; + case 75: return 1024; + case 116: return 512; } return 0; } @@ -4964,29 +5061,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163: case 164: - case 166: case 165: - case 230: - case 231: case 167: - case 161: - case 169: + case 166: + case 231: + case 232: + case 168: case 162: - case 183: case 170: - case 66: - case 9: - case 7: - case 8: + case 163: + case 184: + case 171: + case 67: case 10: - case 180: - case 81: - case 90: - case 94: - case 96: - case 92: + case 8: + case 9: + case 11: + case 181: + case 82: + case 91: + case 95: + case 97: + case 93: return true; } } @@ -4994,12 +5091,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 && token <= 65; + return token >= 55 && token <= 66; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 && - node.parent.token === 80 && + return node.kind === 186 && + node.parent.token === 81 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5008,10 +5105,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66) { + if (node.kind === 67) { return true; } - else if (node.kind === 163) { + else if (node.kind === 164) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5019,10 +5116,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 && node.parent.right === node) || - (node.parent.kind === 163 && node.parent.name === node); + return (node.parent.kind === 133 && node.parent.right === node) || + (node.parent.kind === 164 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163) { + return expression.properties.length === 0; + } + if (kind === 162) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -5226,9 +5334,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134) { + if (d && d.kind === 135) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { return current; } } @@ -5240,7 +5348,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269); + var nodeConstructors = new Array(270); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5278,20 +5386,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132: + case 133: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134: + case 135: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135: + case 136: + case 139: case 138: - case 137: - case 242: case 243: - case 208: - case 160: + case 244: + case 209: + case 161: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5300,24 +5408,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149: case 150: - case 144: + case 151: case 145: case 146: + case 147: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: + case 211: + case 172: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5328,160 +5436,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148: + case 149: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147: + case 148: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151: - return visitNode(cbNode, node.exprName); case 152: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 153: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 154: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 155: + return visitNodes(cbNodes, node.elementTypes); case 156: - return visitNodes(cbNodes, node.types); case 157: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 158: + return visitNode(cbNode, node.type); case 159: - return visitNodes(cbNodes, node.elements); - case 161: + case 160: return visitNodes(cbNodes, node.elements); case 162: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 163: + return visitNodes(cbNodes, node.properties); + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164: + case 165: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165: case 166: + case 167: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167: + case 168: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168: + case 169: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169: - return visitNode(cbNode, node.expression); - case 172: + case 170: return visitNode(cbNode, node.expression); case 173: return visitNode(cbNode, node.expression); case 174: return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); case 177: return visitNode(cbNode, node.operand); + case 182: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.operand); + case 179: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186: + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179: + case 180: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182: + case 183: return visitNode(cbNode, node.expression); - case 189: - case 216: + case 190: + case 217: return visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190: + case 191: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209: + case 210: return visitNodes(cbNodes, node.declarations); - case 192: - return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194: + case 195: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 197: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 198: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 199: - case 200: - return visitNode(cbNode, node.label); - case 201: - return visitNode(cbNode, node.expression); - case 202: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 200: + case 201: + return visitNode(cbNode, node.label); + case 202: + return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217: + case 218: return visitNodes(cbNodes, node.clauses); - case 238: + case 239: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239: + case 240: return visitNodes(cbNodes, node.statements); - case 204: + case 205: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205: - return visitNode(cbNode, node.expression); case 206: + return visitNode(cbNode, node.expression); + case 207: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241: + case 242: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 211: - case 183: - 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 212: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5493,125 +5594,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 244: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 245: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219: + case 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220: + case 221: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221: - return visitNode(cbNode, node.name); case 222: - case 226: + return visitNode(cbNode, node.name); + case 223: + case 227: return visitNodes(cbNodes, node.elements); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223: - case 227: + case 224: + case 228: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180: + case 181: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133: + case 134: return visitNode(cbNode, node.expression); - case 240: + case 241: return visitNodes(cbNodes, node.types); - case 185: + case 186: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229: - return visitNode(cbNode, node.expression); - case 228: - return visitNodes(cbNodes, node.decorators); case 230: + return visitNode(cbNode, node.expression); + case 229: + return visitNodes(cbNodes, node.decorators); + case 231: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231: case 232: + case 233: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236: - return visitNode(cbNode, node.expression); case 237: return visitNode(cbNode, node.expression); - case 234: + case 238: + return visitNode(cbNode, node.expression); + case 235: return visitNode(cbNode, node.tagName); - case 246: + case 247: return visitNode(cbNode, node.type); - case 250: - return visitNodes(cbNodes, node.types); case 251: return visitNodes(cbNodes, node.types); - case 249: + case 252: + return visitNodes(cbNodes, node.types); + case 250: return visitNode(cbNode, node.elementType); + case 254: + return visitNode(cbNode, node.type); case 253: return visitNode(cbNode, node.type); - case 252: - return visitNode(cbNode, node.type); - case 254: + case 255: return visitNodes(cbNodes, node.members); - case 256: + case 257: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257: - return visitNode(cbNode, node.type); case 258: + return visitNode(cbNode, node.type); + case 259: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259: - return visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: return visitNode(cbNode, node.type); - case 255: + case 262: + return visitNode(cbNode, node.type); + case 256: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262: + case 263: return visitNodes(cbNodes, node.tags); - case 264: + case 265: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265: - return visitNode(cbNode, node.typeExpression); case 266: return visitNode(cbNode, node.typeExpression); case 267: + return visitNode(cbNode, node.typeExpression); + case 268: return visitNodes(cbNodes, node.typeParameters); } } @@ -5707,9 +5815,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 190: - case 210: - case 135: + case 191: + case 211: + case 136: addJSDocComment(node); } forEachChild(node, visit); @@ -5747,7 +5855,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245, 0); + var sourceFile = createNode(246, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5880,6 +5988,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -5903,20 +6014,23 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 66) { + if (token === 67) { return true; } - if (token === 111 && inYieldContext()) { + if (token === 112 && inYieldContext()) { return false; } - if (token === 116 && inAwaitContext()) { + if (token === 117 && inAwaitContext()) { return false; } - return token > 102; + return token > 103; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } if (diagnosticMessage) { @@ -5950,20 +6064,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token === 22) { + if (token === 23) { return true; } - return token === 15 || token === 1 || scanner.hasPrecedingLineBreak(); + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22) { + if (token === 23) { nextToken(); } return true; } else { - return parseExpected(22); + return parseExpected(23); } } function createNode(kind, pos) { @@ -6005,15 +6119,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66); - if (token !== 66) { + var node = createNode(67); + if (token !== 67) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6023,14 +6137,14 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 || - token === 7; + token === 9 || + token === 8; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 || token === 7) { + if (token === 9 || token === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token === 18) { + if (allowComputedPropertyNames && token === 19) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -6042,30 +6156,30 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 8 || token === 7 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(133); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(134); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71) { - return nextToken() === 78; + if (token === 72) { + return nextToken() === 79; } - if (token === 79) { + if (token === 80) { nextToken(); - if (token === 74) { + if (token === 75) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 && token !== 14 && canFollowModifier(); + return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 74) { + if (token === 75) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -6075,14 +6189,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 - || token === 14 - || token === 36 + return token === 19 + || token === 15 + || token === 37 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 || token === 84; + return token === 71 || token === 85; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6093,21 +6207,21 @@ var ts; case 0: case 1: case 3: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 68 || token === 74; + return token === 69 || token === 75; case 4: return isStartOfTypeMember(); case 5: - return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: - return token === 18 || isLiteralPropertyName(); + return token === 19 || isLiteralPropertyName(); case 12: - return token === 18 || token === 36 || isLiteralPropertyName(); + return token === 19 || token === 37 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: - if (token === 14) { + if (token === 15) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -6119,23 +6233,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token === 23 || token === 21 || isIdentifierOrPattern(); + return token === 24 || token === 22 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token === 23 || token === 21 || isStartOfExpression(); + return token === 24 || token === 22 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token === 23 || isStartOfType(); + return token === 24 || isStartOfType(); case 20: return isHeritageClause(); case 21: return isIdentifierOrKeyword(); case 13: - return isIdentifierOrKeyword() || token === 14; + return isIdentifierOrKeyword() || token === 15; case 14: return true; case 22: @@ -6148,10 +6262,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14); - if (nextToken() === 15) { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { var next = nextToken(); - return next === 23 || next === 14 || next === 80 || next === 103; + return next === 24 || next === 15 || next === 81 || next === 104; } return true; } @@ -6164,8 +6278,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6187,39 +6301,39 @@ var ts; case 12: case 9: case 21: - return token === 15; + return token === 16; case 3: - return token === 15 || token === 68 || token === 74; + return token === 16 || token === 69 || token === 75; case 7: - return token === 14 || token === 80 || token === 103; + return token === 15 || token === 81 || token === 104; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; + return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; case 11: - return token === 17 || token === 22; + return token === 18 || token === 23; case 15: case 19: case 10: - return token === 19; + return token === 20; case 16: - return token === 17 || token === 19; + return token === 18 || token === 20; case 18: - return token === 26 || token === 16; + return token === 27 || token === 17; case 20: - return token === 14 || token === 15; + return token === 15 || token === 16; case 13: - return token === 26 || token === 37; + return token === 27 || token === 38; case 14: - return token === 24 && lookAhead(nextTokenIsSlash); + return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 17 || token === 52 || token === 15; + return token === 18 || token === 53 || token === 16; case 23: - return token === 26 || token === 15; + return token === 27 || token === 16; case 25: - return token === 19 || token === 15; + return token === 20 || token === 16; case 24: - return token === 15; + return token === 16; } } function isVariableDeclaratorListTerminator() { @@ -6229,7 +6343,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6334,17 +6448,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141: - case 146: case 142: + case 147: case 143: - case 138: - case 188: + case 144: + case 139: + case 189: return true; - case 140: + case 141: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 && - methodDeclaration.name.originalKeywordKind === 118; + var nameIsConstructor = methodDeclaration.name.kind === 67 && + methodDeclaration.name.originalKeywordKind === 119; return !nameIsConstructor; } } @@ -6353,8 +6467,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6363,65 +6477,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210: + case 211: + case 191: case 190: - case 189: + case 194: case 193: - case 192: - case 205: + case 206: + case 202: + case 204: case 201: - case 203: case 200: + case 198: case 199: case 197: - case 198: case 196: - case 195: - case 202: - case 191: - case 206: - case 204: - case 194: + case 203: + case 192: case 207: + case 205: + case 195: + case 208: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 215: - case 211: + case 216: case 212: - case 214: case 213: + case 215: + case 214: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244; + return node.kind === 245; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145: - case 139: case 146: - case 137: - case 144: + case 140: + case 147: + case 138: + case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208) { + if (node.kind !== 209) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135) { + if (node.kind !== 136) { return false; } var parameter = node; @@ -6476,15 +6590,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23)) { + if (parseOptional(24)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(23); - if (considerSemicolonAsDelimeter && token === 22 && !scanner.hasPrecedingLineBreak()) { + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -6520,8 +6634,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20)) { - var node = createNode(132, entity.pos); + while (parseOptional(21)) { + var node = createNode(133, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6532,34 +6646,34 @@ var ts; if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180); + var template = createNode(181); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187); + var span = createNode(188); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15) { + if (token === 16) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13, false, ts.Diagnostics._0_expected, ts.tokenToString(15)); + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); } span.literal = literal; return finishNode(span); @@ -6577,7 +6691,7 @@ var ts; var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 7 + if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536; @@ -6586,30 +6700,30 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147, typeName.pos); + var node_1 = createNode(148, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148, typeName.pos); + var node = createNode(149, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151); - parseExpected(98); + var node = createNode(152); + parseExpected(99); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134); + var node = createNode(135); node.name = parseIdentifier(); - if (parseOptional(80)) { + if (parseOptional(81)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6620,20 +6734,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24) { - return parseBracketedList(17, parseTypeParameter, 24, 26); + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); } } function parseParameterType() { - if (parseOptional(52)) { - return token === 8 + if (parseOptional(53)) { + return token === 9 ? parseLiteralNode(true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6642,15 +6756,15 @@ var ts; } } function parseParameter() { - var node = createNode(135); + var node = createNode(136); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(51); + node.questionToken = parseOptionalToken(52); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6662,7 +6776,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33; + var returnTokenRequired = returnToken === 34; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -6674,7 +6788,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6682,7 +6796,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17) && requireCompleteParameterList) { + if (!parseExpected(18) && requireCompleteParameterList) { return undefined; } return result; @@ -6690,29 +6804,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(23)) { + if (parseOptional(24)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145) { - parseExpected(89); + if (kind === 146) { + parseExpected(90); } - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18) { + if (token !== 19) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token === 21 || token === 19) { + if (token === 22 || token === 20) { return true; } if (ts.isModifier(token)) { @@ -6727,20 +6841,20 @@ var ts; else { nextToken(); } - if (token === 52 || token === 23) { + if (token === 53 || token === 24) { return true; } - if (token !== 51) { + if (token !== 52) { return false; } nextToken(); - return token === 52 || token === 23 || token === 19; + return token === 53 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146, fullStart); + var node = createNode(147, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6748,17 +6862,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (token === 16 || token === 24) { - var method = createNode(139, fullStart); + var questionToken = parseOptionalToken(52); + if (token === 17 || token === 25) { + var method = createNode(140, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(52, false, false, false, method); + fillSignature(53, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137, fullStart); + var property = createNode(138, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6768,9 +6882,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16: - case 24: - case 18: + case 17: + case 25: + case 19: return true; default: if (ts.isModifier(token)) { @@ -6790,27 +6904,27 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 || - token === 24 || - token === 51 || + return token === 17 || + token === 25 || token === 52 || + token === 53 || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16: - case 24: - return parseSignatureMember(144); - case 18: + case 17: + case 25: + return parseSignatureMember(145); + case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 89: + case 90: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145); + return parseSignatureMember(146); } + case 9: case 8: - case 7: return parsePropertyOrMethodSignature(); default: if (ts.isModifier(token)) { @@ -6834,18 +6948,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 || token === 24; + return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(152); + var node = createNode(153); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14)) { + if (parseExpected(15)) { members = parseList(4, parseTypeMember); - parseExpected(15); + parseExpected(16); } else { members = createMissingList(); @@ -6853,47 +6967,47 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154); - node.elementTypes = parseBracketedList(19, parseType, 18, 19); + var node = createNode(155); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157); - parseExpected(16); - node.type = parseType(); + var node = createNode(158); parseExpected(17); + node.type = parseType(); + parseExpected(18); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150) { - parseExpected(89); + if (kind === 151) { + parseExpected(90); } - fillSignature(33, false, false, false, node); + fillSignature(34, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 ? undefined : node; + return token === 21 ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: + case 126: + case 118: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100: + case 101: return parseTokenNode(); - case 98: + case 99: return parseTypeQuery(); - case 14: + case 15: return parseTypeLiteral(); - case 18: + case 19: return parseTupleType(); - case 16: + case 17: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -6901,19 +7015,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 98: - case 14: - case 18: - case 24: - case 89: + case 126: + case 118: + case 129: + case 101: + case 99: + case 15: + case 19: + case 25: + case 90: return true; - case 16: + case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -6921,13 +7035,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 || isStartOfParameter() || isStartOfType(); + return token === 18 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { - parseExpected(19); - var node = createNode(153, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(154, type.pos); node.elementType = type; type = finishNode(node); } @@ -6949,32 +7063,32 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); } function isStartOfFunctionType() { - if (token === 24) { + if (token === 25) { return true; } - return token === 16 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 || token === 21) { + if (token === 18 || token === 22) { return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 || token === 23 || - token === 51 || token === 54 || + if (token === 53 || token === 24 || + token === 52 || token === 55 || isIdentifier() || ts.isModifier(token)) { return true; } - if (token === 17) { + if (token === 18) { nextToken(); - if (token === 33) { + if (token === 34) { return true; } } @@ -6986,36 +7100,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149); - } - if (token === 89) { return parseFunctionOrConstructorType(150); } + if (token === 90) { + return parseFunctionOrConstructorType(151); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52) ? parseType() : undefined; + return parseOptional(53) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 7: + case 95: + case 93: + case 91: + case 97: + case 82: case 8: - case 10: + case 9: case 11: - case 16: - case 18: - case 14: - case 84: - case 70: - case 89: - case 37: - case 58: - case 66: + case 12: + case 17: + case 19: + case 15: + case 85: + case 71: + case 90: + case 38: + case 59: + case 67: return true; default: return isIdentifier(); @@ -7026,18 +7140,18 @@ var ts; return true; } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 75: - case 98: - case 100: - case 39: + case 76: + case 99: + case 101: case 40: - case 24: - case 116: - case 111: + case 41: + case 25: + case 117: + case 112: return true; default: if (isBinaryOperator()) { @@ -7047,10 +7161,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && - token !== 84 && - token !== 70 && - token !== 53 && + return token !== 15 && + token !== 85 && + token !== 71 && + token !== 54 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7066,7 +7180,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23))) { + while ((operatorToken = parseOptionalToken(24))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -7075,12 +7189,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { + if (token !== 55) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(54); + parseExpected(55); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7101,7 +7215,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 66 && token === 33) { + if (expr.kind === 67 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7110,7 +7224,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7123,11 +7237,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36); + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7136,15 +7250,15 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171, identifier.pos); - var parameter = createNode(135, identifier.pos); + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172, identifier.pos); + var parameter = createNode(136, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } @@ -7161,78 +7275,78 @@ var ts; } var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 || lastToken === 14) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24 || token === 115) { + if (token === 17 || token === 25 || token === 116) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33) { + if (token === 34) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115) { + if (token === 116) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token !== 16 && token !== 24) { + if (token !== 17 && token !== 25) { return 0; } } var first = token; var second = nextToken(); - if (first === 16) { - if (second === 17) { + if (first === 17) { + if (second === 18) { var third = nextToken(); switch (third) { - case 33: - case 52: - case 14: + case 34: + case 53: + case 15: return 1; default: return 0; } } - if (second === 18 || second === 14) { + if (second === 19 || second === 15) { return 2; } - if (second === 21) { + if (second === 22) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 52) { + if (nextToken() === 53) { return 1; } return 2; } else { - ts.Debug.assert(first === 24); + ts.Debug.assert(first === 25); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80) { + if (third === 81) { var fourth = nextToken(); switch (fourth) { - case 54: - case 26: + case 55: + case 27: return false; default: return true; } } - else if (third === 23) { + else if (third === 24) { return true; } return false; @@ -7249,25 +7363,25 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171); + var node = createNode(172); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(52, false, isAsync, !allowAmbiguity, node); + fillSignature(53, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 33 && token !== 14) { + if (!allowAmbiguity && token !== 34 && token !== 15) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14) { + if (token === 15) { return parseFunctionBlock(false, isAsync, false); } - if (token !== 22 && - token !== 84 && - token !== 70 && + if (token !== 23 && + token !== 85 && + token !== 71 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7277,15 +7391,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(51); + var questionToken = parseOptionalToken(52); if (!questionToken) { return leftOperand; } - var node = createNode(179, leftOperand.pos); + var node = createNode(180, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); + node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7294,7 +7408,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 || t === 131; + return t === 88 || t === 132; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7303,10 +7417,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 && inDisallowInContext()) { + if (token === 88 && inDisallowInContext()) { break; } - if (token === 113) { + if (token === 114) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7322,90 +7436,90 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87) { + if (inDisallowInContext() && token === 88) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50: + case 51: return 1; - case 49: + case 50: return 2; - case 45: - return 3; case 46: + return 3; + case 47: return 4; - case 44: + case 45: return 5; - case 29: case 30: case 31: case 32: + case 33: return 6; - case 24: - case 26: + case 25: case 27: case 28: + case 29: + case 89: case 88: - case 87: - case 113: + case 114: return 7; - case 41: case 42: case 43: + case 44: return 8; - case 34: case 35: - return 9; case 36: + return 9; case 37: case 38: + case 39: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178, left.pos); + var node = createNode(179, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186, left.pos); + var node = createNode(187, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176); + var node = createNode(177); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(174); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function isAwaitExpression() { - if (token === 116) { + if (token === 117) { if (inAwaitContext()) { return true; } @@ -7414,7 +7528,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7424,25 +7538,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return parsePrefixUnaryExpression(); - case 75: + case 76: return parseDeleteExpression(); - case 98: + case 99: return parseTypeOfExpression(); - case 100: + case 101: return parseVoidExpression(); - case 24: + case 25: if (sourceFile.languageVariant !== 1) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(true); } default: return parsePostfixExpressionOrHigher(); @@ -7451,8 +7565,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177, expression.pos); + if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7461,7 +7575,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7472,44 +7586,44 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 || token === 20) { + if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(163, expression.pos); + var node = createNode(164, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232) { - var node = createNode(230, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233) { + var node = createNode(231, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231); + ts.Debug.assert(opening.kind === 232); return opening; } } function parseJsxText() { - var node = createNode(233, scanner.getStartPos()); + var node = createNode(234, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233: + case 234: return parseJsxText(); - case 14: - return parseJsxExpression(); - case 24: - return parseJsxElementOrSelfClosingElement(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -7518,7 +7632,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7531,19 +7645,26 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24); + parseExpected(25); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (parseOptional(26)) { - node = createNode(232, fullStart); + if (token === 27) { + node = createNode(233, fullStart); + scanJsxText(); } else { - parseExpected(37); - parseExpected(26); - node = createNode(231, fullStart); + parseExpected(38); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(232, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7552,95 +7673,107 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20)) { + while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(132, elementName.pos); + var node = createNode(133, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237); - parseExpected(14); - if (token !== 15) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238); + parseExpected(15); + if (token !== 16) { node.expression = parseExpression(); } - parseExpected(15); + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14) { + if (token === 15) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235); + var node = createNode(236); node.name = parseIdentifierName(); - if (parseOptional(54)) { + if (parseOptional(55)) { switch (token) { - case 8: + case 9: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236); - parseExpected(14); - parseExpected(21); - node.expression = parseExpression(); + var node = createNode(237); parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234); - parseExpected(25); - node.tagName = parseJsxElementName(); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235); parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168); - parseExpected(24); + var node = createNode(169); + parseExpected(25); node.type = parseType(); - parseExpected(26); + parseExpected(27); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20); + var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(163, expression.pos); + var propertyAccess = createNode(164, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(164, expression.pos); + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(165, expression.pos); indexedAccess.expression = expression; - if (token !== 19) { + if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 || indexedAccess.argumentExpression.kind === 7) { + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19); + parseExpected(20); expression = finishNode(indexedAccess); continue; } - if (token === 10 || token === 11) { - var tagExpression = createNode(167, expression.pos); + if (token === 11 || token === 12) { + var tagExpression = createNode(168, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 + tagExpression.template = token === 11 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -7652,20 +7785,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24) { + if (token === 25) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(165, expression.pos); + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16) { - var callExpr = createNode(165, expression.pos); + else if (token === 17) { + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7675,17 +7808,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24)) { + if (!parseOptional(25)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(26)) { + if (!parseExpected(27)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7694,108 +7827,108 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16: - case 20: case 17: - case 19: + case 21: + case 18: + case 20: + case 53: + case 23: case 52: - case 22: - case 51: - case 29: - case 31: case 30: case 32: - case 49: + case 31: + case 33: case 50: - case 46: - case 44: + case 51: + case 47: case 45: - case 15: + case 46: + case 16: case 1: return true; - case 23: - case 14: + case 24: + case 15: default: return false; } } function parsePrimaryExpression() { switch (token) { - case 7: case 8: - case 10: + case 9: + case 11: return parseLiteralNode(); - case 94: - case 92: - case 90: - case 96: - case 81: + case 95: + case 93: + case 91: + case 97: + case 82: return parseTokenNode(); - case 16: + case 17: return parseParenthesizedExpression(); - case 18: + case 19: return parseArrayLiteralExpression(); - case 14: + case 15: return parseObjectLiteralExpression(); - case 115: + case 116: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 70: + case 71: return parseClassExpression(); - case 84: + case 85: return parseFunctionExpression(); - case 89: + case 90: return parseNewExpression(); - case 37: - case 58: - if (reScanSlashToken() === 9) { + case 38: + case 59: + if (reScanSlashToken() === 10) { return parseLiteralNode(); } break; - case 11: + case 12: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(170); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182); - parseExpected(21); + var node = createNode(183); + parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(184) : + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(185) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161); - parseExpected(18); + var node = createNode(162); + parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(19); + parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120)) { - return parseAccessorDeclaration(142, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(126)) { + if (parseContextualModifier(121)) { return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } + else if (parseContextualModifier(127)) { + return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -7806,37 +7939,37 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243, fullStart); + if ((token === 24 || token === 16) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242, fullStart); + var propertyAssignment = createNode(243, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52); + parseExpected(53); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162); - parseExpected(14); + var node = createNode(163); + parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(15); + parseExpected(16); return finishNode(node); } function parseFunctionExpression() { @@ -7844,10 +7977,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170); + var node = createNode(171); setModifiers(node, parseModifiers()); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); node.name = @@ -7855,7 +7988,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -7866,20 +7999,20 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166); - parseExpected(89); + var node = createNode(167); + parseExpected(90); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16) { + if (node.typeArguments || token === 17) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189); - if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -7904,47 +8037,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(193); - parseExpected(85); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(194); + parseExpected(86); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194); - parseExpected(76); + var node = createNode(195); + parseExpected(77); node.statement = parseStatement(); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + parseExpected(102); parseExpected(17); - parseOptional(22); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(196); + parseExpected(102); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83); - parseExpected(16); + parseExpected(84); + parseExpected(17); var initializer = undefined; - if (token !== 22) { - if (token === 99 || token === 105 || token === 71) { + if (token !== 23) { + if (token === 100 || token === 106 || token === 72) { initializer = parseVariableDeclarationList(true); } else { @@ -7952,32 +8085,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(87)) { - var forInStatement = createNode(197, pos); + if (parseOptional(88)) { + var forInStatement = createNode(198, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131)) { - var forOfStatement = createNode(198, pos); + else if (parseOptional(132)) { + var forOfStatement = createNode(199, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196, pos); + var forStatement = createNode(197, pos); forStatement.initializer = initializer; - parseExpected(22); - if (token !== 22 && token !== 17) { + parseExpected(23); + if (token !== 23 && token !== 18) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22); - if (token !== 17) { + parseExpected(23); + if (token !== 18) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -7985,7 +8118,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 ? 67 : 72); + parseExpected(kind === 201 ? 68 : 73); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7993,8 +8126,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201); - parseExpected(91); + var node = createNode(202); + parseExpected(92); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8002,99 +8135,99 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202); - parseExpected(102); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(203); + parseExpected(103); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238); - parseExpected(68); + var node = createNode(239); + parseExpected(69); node.expression = allowInAnd(parseExpression); - parseExpected(52); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239); - parseExpected(74); - parseExpected(52); + var node = createNode(240); + parseExpected(75); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 ? parseCaseClause() : parseDefaultClause(); + return token === 69 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203); - parseExpected(93); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(94); parseExpected(17); - var caseBlock = createNode(217, scanner.getStartPos()); - parseExpected(14); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(218, scanner.getStartPos()); parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(205); - parseExpected(95); + var node = createNode(206); + parseExpected(96); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(206); - parseExpected(97); + var node = createNode(207); + parseExpected(98); node.tryBlock = parseBlock(false); - node.catchClause = token === 69 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 82) { - parseExpected(82); + node.catchClause = token === 70 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 83) { + parseExpected(83); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241); - parseExpected(69); - if (parseExpected(16)) { + var result = createNode(242); + parseExpected(70); + if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17); + parseExpected(18); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207); - parseExpected(73); + var node = createNode(208); + parseExpected(74); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 && parseOptional(52)) { - var labeledStatement = createNode(204, fullStart); + if (expression.kind === 67 && parseOptional(53)) { + var labeledStatement = createNode(205, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192, fullStart); + var expressionStatement = createNode(193, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66; + return token >= 67; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -8102,51 +8235,51 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 && !scanner.hasPrecedingLineBreak(); + return token === 85 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99: - case 105: + case 100: + case 106: + case 72: + case 85: case 71: - case 84: - case 70: - case 78: + case 79: return true; - case 104: - case 129: + case 105: + case 130: return nextTokenIsIdentifierOnSameLine(); - case 122: case 123: + case 124: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 119: + case 116: + case 120: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86: + case 87: nextToken(); - return token === 8 || token === 36 || - token === 14 || isIdentifierOrKeyword(); - case 79: + return token === 9 || token === 37 || + token === 15 || isIdentifierOrKeyword(); + case 80: nextToken(); - if (token === 54 || token === 36 || - token === 14 || token === 74) { + if (token === 55 || token === 37 || + token === 15 || token === 75) { return true; } continue; - case 109: - case 107: - case 108: case 110: - case 112: + case 108: + case 109: + case 111: + case 113: nextToken(); continue; default: @@ -8159,44 +8292,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53: - case 22: - case 14: - case 99: - case 105: - case 84: - case 70: - case 78: + case 54: + case 23: + case 15: + case 100: + case 106: case 85: - case 76: - case 101: - case 83: - case 72: - case 67: - case 91: - case 102: - case 93: - case 95: - case 97: - case 73: - case 69: - case 82: - return true; case 71: case 79: case 86: - return isStartOfDeclaration(); - case 115: - case 119: - case 104: - case 122: - case 123: - case 129: + case 77: + case 102: + case 84: + case 73: + case 68: + case 92: + case 103: + case 94: + case 96: + case 98: + case 74: + case 70: + case 83: + return true; + case 72: + case 80: + case 87: + return isStartOfDeclaration(); + case 116: + case 120: + case 105: + case 123: + case 124: + case 130: return true; - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8204,71 +8337,71 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 || token === 18; + return isIdentifier() || token === 15 || token === 19; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token) { - case 22: + case 23: return parseEmptyStatement(); - case 14: + case 15: return parseBlock(false); - case 99: + case 100: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105: + case 106: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 84: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - return parseIfStatement(); - case 76: - return parseDoStatement(); - case 101: - return parseWhileStatement(); - case 83: - return parseForOrForInOrForOfStatement(); - case 72: - return parseBreakOrContinueStatement(199); - case 67: - return parseBreakOrContinueStatement(200); - case 91: - return parseReturnStatement(); - case 102: - return parseWithStatement(); - case 93: - return parseSwitchStatement(); - case 95: - return parseThrowStatement(); - case 97: - case 69: - case 82: - return parseTryStatement(); - case 73: - return parseDebuggerStatement(); - case 53: - return parseDeclaration(); - case 115: - case 104: - case 129: - case 122: - case 123: - case 119: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 71: - case 78: - case 79: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 86: - case 107: + return parseIfStatement(); + case 77: + return parseDoStatement(); + case 102: + return parseWhileStatement(); + case 84: + return parseForOrForInOrForOfStatement(); + case 73: + return parseBreakOrContinueStatement(200); + case 68: + return parseBreakOrContinueStatement(201); + case 92: + return parseReturnStatement(); + case 103: + return parseWithStatement(); + case 94: + return parseSwitchStatement(); + case 96: + return parseThrowStatement(); + case 98: + case 70: + case 83: + return parseTryStatement(); + case 74: + return parseDebuggerStatement(); + case 54: + return parseDeclaration(); + case 116: + case 105: + case 130: + case 123: + case 124: + case 120: + case 72: + case 79: + case 80: + case 87: case 108: case 109: - case 112: case 110: + case 113: + case 111: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8281,33 +8414,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99: - case 105: - case 71: + case 100: + case 106: + case 72: return parseVariableStatement(fullStart, decorators, modifiers); - case 84: + case 85: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70: + case 71: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104: + case 105: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129: + case 130: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122: - case 123: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 79: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 123: + case 124: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 87: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 80: nextToken(); - return token === 74 || token === 54 ? + return token === 75 || token === 55 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8317,34 +8450,34 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 && canParseSemicolon()) { + if (token !== 15 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token === 23) { - return createNode(184); + if (token === 24) { + return createNode(185); } - var node = createNode(160); - node.dotDotDotToken = parseOptionalToken(21); + var node = createNode(161); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160); + var node = createNode(161); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52) { + if (tokenIsIdentifier && token !== 53) { node.name = propertyName; } else { - parseExpected(52); + parseExpected(53); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8352,33 +8485,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158); - parseExpected(14); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(159); parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159); - parseExpected(18); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(160); parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 || token === 18 || isIdentifier(); + return token === 15 || token === 19 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18) { + if (token === 19) { return parseArrayBindingPattern(); } - if (token === 14) { + if (token === 15) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208); + var node = createNode(209); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8387,21 +8520,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209); + var node = createNode(210); switch (token) { - case 99: + case 100: break; - case 105: + case 106: node.flags |= 16384; break; - case 71: + case 72: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8413,10 +8546,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17; + return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190, fullStart); + var node = createNode(191, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8424,29 +8557,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210, fullStart); + var node = createNode(211, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141, pos); + var node = createNode(142, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118); - fillSignature(52, false, false, false, node); + parseExpected(119); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140, fullStart); + var method = createNode(141, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8454,12 +8587,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(52, isGenerator, isAsync, false, method); + fillSignature(53, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138, fullStart); + var property = createNode(139, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8472,10 +8605,10 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -8490,16 +8623,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return true; default: return false; @@ -8507,7 +8640,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8517,26 +8650,26 @@ var ts; } nextToken(); } - if (token === 36) { + if (token === 37) { return true; } if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 18) { + if (token === 19) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { + if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { return true; } switch (token) { - case 16: - case 24: + case 17: + case 25: + case 53: + case 55: case 52: - case 54: - case 51: return true; default: return canParseSemicolon(); @@ -8548,14 +8681,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53)) { + if (!parseOptional(54)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136, decoratorStart); + var decorator = createNode(137, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8589,7 +8722,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115) { + if (token === 116) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8603,8 +8736,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22) { - var result = createNode(188); + if (token === 23) { + var result = createNode(189); nextToken(); return finishNode(result); } @@ -8615,42 +8748,42 @@ var ts; if (accessor) { return accessor; } - if (token === 118) { + if (token === 119) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || + token === 9 || token === 8 || - token === 7 || - token === 36 || - token === 18) { + token === 37 || + token === 19) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_8 = createMissingNode(66, true, ts.Diagnostics.Declaration_expected); + var name_8 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70); + parseExpected(71); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseClassMembers(); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8669,8 +8802,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 || token === 103) { - var node = createNode(240); + if (token === 81 || token === 104) { + var node = createNode(241); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8679,24 +8812,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185); + var node = createNode(186); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function isHeritageClause() { - return token === 80 || token === 103; + return token === 81 || token === 104; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104); + parseExpected(105); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8704,32 +8837,32 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129); + parseExpected(130); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54); + parseExpected(55); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(245, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78); + parseExpected(79); node.name = parseIdentifier(); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8737,10 +8870,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216, scanner.getStartPos()); - if (parseExpected(14)) { + var node = createNode(217, scanner.getStartPos()); + if (parseExpected(15)) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -8748,18 +8881,18 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20) + node.body = parseOptional(21) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8768,57 +8901,57 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123)) { + if (parseOptional(124)) { flags |= 131072; } else { - parseExpected(122); - if (token === 8) { + parseExpected(123); + if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 && + return token === 125 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16; + return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 37; + return nextToken() === 38; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 || - token === 130; + return token === 24 || + token === 131; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86); + parseExpected(87); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 130) { - var importEqualsDeclaration = createNode(218, fullStart); + if (token !== 24 && token !== 131) { + var importEqualsDeclaration = createNode(219, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54); + parseExpected(55); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(219, fullStart); + var importDeclaration = createNode(220, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 36 || - token === 14) { + token === 37 || + token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130); + parseExpected(131); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -8831,13 +8964,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220, fullStart); + var importClause = createNode(221, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(23)) { - importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); } return finishNode(importClause); } @@ -8847,37 +8980,37 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(229); - parseExpected(124); - parseExpected(16); - node.expression = parseModuleSpecifier(); + var node = createNode(230); + parseExpected(125); parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); return finishNode(node); } function parseModuleSpecifier() { var result = parseExpression(); - if (result.kind === 8) { + if (result.kind === 9) { internIdentifier(result.text); } return result; } function parseNamespaceImport() { - var namespaceImport = createNode(221); - parseExpected(36); - parseExpected(113); + var namespaceImport = createNode(222); + parseExpected(37); + parseExpected(114); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227); + return parseImportOrExportSpecifier(228); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223); + return parseImportOrExportSpecifier(224); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8885,9 +9018,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113) { + if (token === 114) { node.propertyName = identifierName; - parseExpected(113); + parseExpected(114); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -8896,23 +9029,23 @@ var ts; else { node.name = identifierName; } - if (kind === 223 && checkIdentifierIsKeyword) { + if (kind === 224 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36)) { - parseExpected(130); + if (parseOptional(37)) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226); - if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { - parseExpected(130); + node.exportClause = parseNamedImportsOrExports(227); + if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8920,14 +9053,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54)) { + if (parseOptional(55)) { node.isExportEquals = true; } else { - parseExpected(74); + parseExpected(75); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -8990,10 +9123,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 218 && node.moduleReference.kind === 229 - || node.kind === 219 - || node.kind === 224 + || node.kind === 219 && node.moduleReference.kind === 230 + || node.kind === 220 || node.kind === 225 + || node.kind === 226 ? node : undefined; }); @@ -9002,16 +9135,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36: - case 51: - case 16: - case 18: - case 47: - case 14: - case 84: - case 21: - case 89: - case 94: + case 37: + case 52: + case 17: + case 19: + case 48: + case 15: + case 85: + case 22: + case 90: + case 95: return true; } return isIdentifierOrKeyword(); @@ -9028,23 +9161,23 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(246); - parseExpected(14); - result.type = parseJSDocTopLevelType(); + var result = createNode(247); parseExpected(15); + result.type = parseJSDocTopLevelType(); + parseExpected(16); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45) { - var unionType = createNode(250, type.pos); + if (token === 46) { + var unionType = createNode(251, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54) { - var optionalType = createNode(257, type.pos); + if (token === 55) { + var optionalType = createNode(258, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9054,21 +9187,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18) { - var arrayType = createNode(249, type.pos); + if (token === 19) { + var arrayType = createNode(250, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19); + parseExpected(20); type = finishNode(arrayType); } - else if (token === 51) { - var nullableType = createNode(252, type.pos); + else if (token === 52) { + var nullableType = createNode(253, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47) { - var nonNullableType = createNode(253, type.pos); + else if (token === 48) { + var nonNullableType = createNode(254, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9081,85 +9214,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36: + case 37: return parseJSDocAllType(); - case 51: + case 52: return parseJSDocUnknownOrNullableType(); - case 16: + case 17: return parseJSDocUnionType(); - case 18: + case 19: return parseJSDocTupleType(); - case 47: + case 48: return parseJSDocNonNullableType(); - case 14: + case 15: return parseJSDocRecordType(); - case 84: + case 85: return parseJSDocFunctionType(); - case 21: + case 22: return parseJSDocVariadicType(); - case 89: + case 90: return parseJSDocConstructorType(); - case 94: + case 95: return parseJSDocThisType(); - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: + case 126: + case 118: + case 129: + case 101: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261); + var result = createNode(262); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260); + var result = createNode(261); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258); + var result = createNode(259); nextToken(); - parseExpected(16); + parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17); - if (token === 52) { + parseExpected(18); + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135); + var parameter = createNode(136); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257, type.pos); + var result = createNode(258, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256); + var result = createNode(257); result.name = parseSimplePropertyName(); - while (parseOptional(20)) { - if (token === 24) { + while (parseOptional(21)) { + if (token === 25) { result.typeArguments = parseTypeArguments(); break; } @@ -9174,7 +9307,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9185,40 +9318,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132, left.pos); + var result = createNode(133, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254); + var result = createNode(255); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15); + parseExpected(16); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255); + var result = createNode(256); result.name = parseSimplePropertyName(); - if (token === 52) { + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253); + var result = createNode(254); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251); + var result = createNode(252); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19); + parseExpected(20); return finishNode(result); } function checkForTrailingComma(list) { @@ -9228,10 +9361,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250); + var result = createNode(251); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17); + parseExpected(18); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -9239,31 +9372,31 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45)) { + while (parseOptional(46)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247); + var result = createNode(248); nextToken(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token === 23 || - token === 15 || - token === 17 || - token === 26 || - token === 54 || - token === 45) { - var result = createNode(248, pos); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 55 || + token === 46) { + var result = createNode(249, pos); return finishNode(result); } else { - var result = createNode(252, pos); + var result = createNode(253, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9334,7 +9467,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262, start); + var result = createNode(263, start); result.tags = tags; return finishNode(result, end); } @@ -9345,7 +9478,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(53, pos - 1); + var atToken = createNode(54, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9371,7 +9504,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9423,7 +9556,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264, atToken.pos); + var result = createNode(265, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9433,16 +9566,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(265, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -9452,10 +9575,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -9466,7 +9599,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134, name_9.pos); + var typeParameter = createNode(135, name_9.pos); typeParameter.name = name_9; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9477,7 +9610,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9498,7 +9631,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66, startPos); + var result = createNode(67, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9542,7 +9675,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9572,9 +9705,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { + case 9: case 8: - case 7: - case 66: + case 67: return true; } return false; @@ -9793,16 +9926,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 212 || node.kind === 213) { + if (node.kind === 213 || node.kind === 214) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { + else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { return 0; } - else if (node.kind === 216) { + else if (node.kind === 217) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9818,7 +9951,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -9870,10 +10003,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 && node.name.kind === 8) { - return '"' + node.name.text + '"'; + if (node.kind === 216 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133) { + if (node.name.kind === 134) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -9881,22 +10014,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141: + case 142: return "__constructor"; - case 149: - case 144: - return "__call"; case 150: case 145: - return "__new"; + return "__call"; + case 151: case 146: + return "__new"; + case 147: return "__index"; - case 225: + case 226: return "__export"; - case 224: + case 225: return node.isExportEquals ? "export=" : "default"; - case 210: case 211: + case 212: return node.flags & 1024 ? "default" : undefined; } } @@ -9938,7 +10071,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { + if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -9984,37 +10117,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183: - case 211: + case 184: case 212: - case 214: - case 152: - case 162: + case 213: + case 215: + case 153: + case 163: return 1; - case 144: case 145: case 146: - case 140: - case 139: - case 210: + case 147: case 141: + case 140: + case 211: case 142: case 143: - case 149: + case 144: case 150: - case 170: + case 151: case 171: - case 215: - case 245: - case 213: + case 172: + case 216: + case 246: + case 214: return 5; - case 241: - case 196: + case 242: case 197: case 198: - case 217: + case 199: + case 218: return 2; - case 189: + case 190: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10030,33 +10163,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 215: + case 216: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245: + case 246: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183: - case 211: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 214: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 162: + case 184: case 212: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 215: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 153: + case 163: + case 213: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149: case 150: - case 144: + case 151: case 145: case 146: - case 140: - case 139: + case 147: case 141: + case 140: case 142: case 143: - case 210: - case 170: + case 144: + case 211: case 171: - case 213: + case 172: + case 214: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -10080,11 +10213,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 ? node : node.body; - if (body.kind === 245 || body.kind === 216) { + var body = node.kind === 246 ? node : node.body; + if (body.kind === 246 || body.kind === 217) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 || stat.kind === 224) { + if (stat.kind === 226 || stat.kind === 225) { return true; } } @@ -10101,7 +10234,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8) { + if (node.name.kind === 9) { declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -10111,12 +10244,17 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512, 106639); - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; } else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -10134,11 +10272,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66) { + if (prop.name.kind !== 67) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 + var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10160,10 +10298,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215: + case 216: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245: + case 246: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10181,8 +10319,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 && - node.originalKeywordKind <= 111 && + node.originalKeywordKind >= 104 && + node.originalKeywordKind <= 112 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -10209,17 +10347,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 66) { + if (inStrictMode && node.expression.kind === 67) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66) { + if (name && name.kind === 67) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -10253,7 +10391,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 39 || node.operator === 40) { + if (node.operator === 40 || node.operator === 41) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -10282,17 +10420,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245: - case 216: + case 246: + case 217: updateStrictModeStatementList(node.statements); return; - case 189: + case 190: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211: - case 183: + case 212: + case 184: inStrictMode = true; return; } @@ -10311,106 +10449,106 @@ var ts; } function isUseStrictPrologueDirective(node) { var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66: + case 67: return checkStrictModeIdentifier(node); - case 178: + case 179: return checkStrictModeBinaryExpression(node); - case 241: - return checkStrictModeCatchClause(node); - case 172: - return checkStrictModeDeleteExpression(node); - case 7: - return checkStrictModeNumericLiteral(node); - case 177: - return checkStrictModePostfixUnaryExpression(node); - case 176: - return checkStrictModePrefixUnaryExpression(node); - case 202: - return checkStrictModeWithStatement(node); - case 134: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 135: - return bindParameter(node); - case 208: - case 160: - return bindVariableDeclarationOrBindingElement(node); - case 138: - case 137: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 242: + return checkStrictModeCatchClause(node); + case 173: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 178: + return checkStrictModePostfixUnaryExpression(node); + case 177: + return checkStrictModePrefixUnaryExpression(node); + case 203: + return checkStrictModeWithStatement(node); + case 135: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 136: + return bindParameter(node); + case 209: + case 161: + return bindVariableDeclarationOrBindingElement(node); + case 139: + case 138: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 243: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 244: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 245: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 144: case 145: case 146: + case 147: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 141: case 140: - case 139: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 210: + case 211: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 141: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 142: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 143: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 144: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 149: case 150: + case 151: return bindFunctionOrConstructorType(node); - case 152: + case 153: return bindAnonymousDeclaration(node, 2048, "__type"); - case 162: + case 163: return bindObjectLiteralExpression(node); - case 170: case 171: + case 172: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 183: - case 211: - return bindClassLikeDeclaration(node); + case 184: case 212: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 213: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 214: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 215: + return bindEnumDeclaration(node); + case 216: return bindModuleDeclaration(node); - case 218: - case 221: - case 223: - case 227: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 220: - return bindImportClause(node); - case 225: - return bindExportDeclaration(node); + case 219: + case 222: case 224: + case 228: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 221: + return bindImportClause(node); + case 226: + return bindExportDeclaration(node); + case 225: return bindExportAssignment(node); - case 245: + case 246: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 66) { + else if (node.expression.kind === 67) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -10431,7 +10569,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -10481,7 +10619,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 141 && + node.parent.kind === 142 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -10536,17 +10674,18 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -10563,7 +10702,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -10571,16 +10711,17 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(4194304, "symbol"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); - var nullType = createIntrinsicType(64 | 1048576, "null"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -10624,6 +10765,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10645,7 +10787,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10658,6 +10800,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10799,10 +10942,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245); + return ts.getAncestor(node, 246); } function isGlobalSourceFile(node) { - return node.kind === 245 && !ts.isExternalModule(node); + return node.kind === 246 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10825,7 +10968,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -10850,16 +10993,16 @@ var ts; } } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) break; - case 215: + case 216: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 || - (location.kind === 215 && location.name.kind === 8)) { + if (location.kind === 246 || + (location.kind === 216 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 227)) { + ts.getDeclarationOfKind(moduleExports[name], 228)) { break; } result = moduleExports["default"]; @@ -10873,13 +11016,13 @@ var ts; break loop; } break; - case 214: + case 215: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 139: case 138: - case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10889,9 +11032,9 @@ var ts; } } break; - case 211: - case 183: case 212: + case 184: + case 213: 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); @@ -10899,7 +11042,7 @@ var ts; } break loop; } - if (location.kind === 183 && meaning & 32) { + if (location.kind === 184 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10907,28 +11050,28 @@ var ts; } } break; - case 133: + case 134: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213) { 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 140: - case 139: case 141: + case 140: case 142: case 143: - case 210: - case 171: + case 144: + case 211: + case 172: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10941,8 +11084,8 @@ var ts; } } break; - case 136: - if (location.parent && location.parent.kind === 135) { + case 137: + if (location.parent && location.parent.kind === 136) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10968,7 +11111,7 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2) { + if (meaning & 2 && result.flags & 2) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -10980,14 +11123,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, 208); + var variableDeclaration = ts.getAncestor(declaration, 209); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 || - variableDeclaration.parent.parent.kind === 196) { + if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 197) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 197) { + else if (variableDeclaration.parent.parent.kind === 199 || + variableDeclaration.parent.parent.kind === 198) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -11009,10 +11152,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } - while (node && node.kind !== 219) { + while (node && node.kind !== 220) { node = node.parent; } return node; @@ -11022,7 +11165,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229) { + if (node.moduleReference.kind === 230) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11111,17 +11254,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218: + case 219: return getTargetOfImportEqualsDeclaration(node); - case 220: - return getTargetOfImportClause(node); case 221: + return getTargetOfImportClause(node); + case 222: return getTargetOfNamespaceImport(node); - case 223: - return getTargetOfImportSpecifier(node); - case 227: - return getTargetOfExportSpecifier(node); case 224: + return getTargetOfImportSpecifier(node); + case 228: + return getTargetOfExportSpecifier(node); + case 225: return getTargetOfExportAssignment(node); } } @@ -11163,10 +11306,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224) { + if (node.kind === 225) { checkExpressionCached(node.expression); } - else if (node.kind === 227) { + else if (node.kind === 228) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -11176,17 +11319,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218); + importDeclaration = ts.getAncestor(entityName, 219); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 66 || entityName.parent.kind === 132) { + if (entityName.kind === 67 || entityName.parent.kind === 133) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 218); + ts.Debug.assert(entityName.parent.kind === 219); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -11198,16 +11341,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66) { + if (name.kind === 67) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 || name.kind === 163) { - var left = name.kind === 132 ? name.left : name.expression; - var right = name.kind === 132 ? name.right : name.name; + else if (name.kind === 133 || name.kind === 164) { + var left = name.kind === 133 ? name.left : name.expression; + var right = name.kind === 133 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11230,35 +11373,24 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8) { + if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -11354,7 +11486,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11419,17 +11551,17 @@ var ts; } } switch (location_1.kind) { - case 245: + case 246: if (!ts.isExternalModule(location_1)) { break; } - case 215: + case 216: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211: case 212: + case 213: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11462,7 +11594,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11491,7 +11623,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11546,8 +11678,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 && declaration.name.kind === 8) || - (declaration.kind === 245 && ts.isExternalModule(declaration)); + return (declaration.kind === 216 && declaration.name.kind === 9) || + (declaration.kind === 246 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11579,11 +11711,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { meaning = 107455 | 1048576; } - else if (entityName.kind === 132 || entityName.kind === 163 || - entityName.parent.kind === 218) { + else if (entityName.kind === 133 || entityName.kind === 164 || + entityName.parent.kind === 219) { meaning = 1536; } else { @@ -11634,16 +11766,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157) { + while (node.kind === 158) { node = node.parent; } - if (node.kind === 213) { + if (node.kind === 214) { return getSymbolOfNode(node); } } return undefined; } - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -11652,10 +11783,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183: + case 184: return "(Anonymous class)"; - case 170: case 171: + case 172: return "(Anonymous function)"; } } @@ -11676,7 +11807,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11718,7 +11849,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 4194431) { + if (type.flags & 16777343) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -11742,23 +11873,23 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 14); - writeSpace(writer); - writePunctuation(writer, 21); - writeSpace(writer); writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23) { + if (delimiter !== 24) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 ? 0 : 64); + writeType(types[i], delimiter === 24 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -11766,22 +11897,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); } if (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeType(typeArguments[pos++], 0); while (pos < end) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 18); writePunctuation(writer, 19); + writePunctuation(writer, 20); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -11796,7 +11927,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } } @@ -11804,18 +11935,18 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18); - writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); } function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 16); - } - writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } + writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + if (flags & 64) { + writePunctuation(writer, 18); + } } function writeAnonymousType(type, flags) { var symbol = type.symbol; @@ -11832,7 +11963,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11853,7 +11984,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 || declaration.parent.kind === 216; + return declaration.parent.kind === 246 || declaration.parent.kind === 217; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11862,7 +11993,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98); + writeKeyword(writer, 99); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11878,74 +12009,74 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14); writePunctuation(writer, 15); + writePunctuation(writer, 16); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } } - writePunctuation(writer, 14); + writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 126); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -11957,27 +12088,27 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15); + writePunctuation(writer, 16); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -11991,7 +12122,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80); + writeKeyword(writer, 81); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11999,67 +12130,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21); + writePunctuation(writer, 22); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17); + writePunctuation(writer, 18); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 33); + writePunctuation(writer, 34); } else { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -12079,15 +12210,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -12096,12 +12224,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215) { - if (node.name.kind === 8) { + if (node.kind === 216) { + if (node.name.kind === 9) { return node; } } - else if (node.kind === 245) { + else if (node.kind === 246) { return ts.isExternalModule(node) ? node : undefined; } } @@ -12144,60 +12272,60 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160: + case 161: return isDeclarationVisible(node.parent.parent); - case 208: + case 209: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 215: - case 211: + case 216: case 212: case 213: - case 210: case 214: - case 218: + case 211: + case 215: + case 219: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 138: - case 137: - case 142: - case 143: - case 140: case 139: + case 138: + case 143: + case 144: + case 141: + case 140: if (node.flags & (32 | 64)) { return false; } - case 141: - case 145: - case 144: + case 142: case 146: - case 135: - case 216: - case 149: + case 145: + case 147: + case 136: + case 217: case 150: - case 152: - case 148: + case 151: case 153: + case 149: case 154: case 155: case 156: case 157: + case 158: return isDeclarationVisible(node.parent); - case 220: case 221: - case 223: - return false; - case 134: - case 245: - return true; + case 222: case 224: return false; + case 135: + case 246: + return true; + case 225: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -12212,11 +12340,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); } var result = []; if (exportSymbol) { @@ -12239,29 +12370,55 @@ 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); + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 208 ? node.parent.parent.parent : node.parent; + return node.kind === 209 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -12287,7 +12444,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var name_11 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_11.text) || isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || @@ -12300,9 +12457,6 @@ var ts; else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -12324,10 +12478,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 197) { + if (declaration.parent.parent.kind === 198) { return anyType; } - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 199) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12336,10 +12490,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var func = declaration.parent; - if (func.kind === 143 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); + if (func.kind === 144 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12352,9 +12506,12 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 243) { + if (declaration.kind === 244) { return checkIdentifier(declaration.name); } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } return undefined; } function getTypeFromBindingElement(element) { @@ -12381,7 +12538,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -12396,7 +12553,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 + return pattern.kind === 159 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -12406,15 +12563,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 242 ? getWidenedType(type) : type; - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12427,13 +12581,13 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241) { + if (declaration.parent.kind === 242) { return links.type = anyType; } - if (declaration.kind === 224) { + if (declaration.kind === 225) { return links.type = checkExpression(declaration.expression); } - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -12455,7 +12609,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142) { + if (accessor.kind === 143) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12468,11 +12622,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142); - var setter = ts.getDeclarationOfKind(symbol, 143); + var getter = ts.getDeclarationOfKind(symbol, 143); + var setter = ts.getDeclarationOfKind(symbol, 144); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12498,7 +12652,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142); + var getter_1 = ts.getDeclarationOfKind(symbol, 143); 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)); } } @@ -12587,9 +12741,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 || node.kind === 183 || - node.kind === 210 || node.kind === 170 || - node.kind === 140 || node.kind === 171) { + if (node.kind === 212 || node.kind === 184 || + node.kind === 211 || node.kind === 171 || + node.kind === 141 || node.kind === 172) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12598,15 +12752,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 || node.kind === 211 || - node.kind === 183 || node.kind === 213) { + if (node.kind === 213 || node.kind === 212 || + node.kind === 184 || node.kind === 214) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12642,7 +12796,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -12711,7 +12865,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12755,10 +12909,10 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12789,7 +12943,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12956,38 +13110,59 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; } function getUnionSignatures(types, kind) { var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } } } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; - } - } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); - } - return result; + return result || emptyArray; } function getUnionIndexType(types, kind) { var indexTypes = []; @@ -13124,9 +13299,6 @@ var ts; return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { - if (type.flags & 16384) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512) { do { type = getConstraintOfTypeParameter(type); @@ -13144,7 +13316,7 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 4194304) { + else if (type.flags & 16777216) { type = globalESSymbolType; } return type; @@ -13225,6 +13397,25 @@ var ts; } return undefined; } + function isKnownProperty(type, name) { + if (type.flags & 80896 && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); @@ -13280,12 +13471,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13294,14 +13495,17 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8) { + if (param.type && param.type.kind === 9) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -13313,7 +13517,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147) { + if (declaration.type.kind === 148) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13323,8 +13527,8 @@ var ts; } } else { - if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143); + if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13342,19 +13546,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149: case 150: - case 210: - case 140: - case 139: + case 151: + case 211: case 141: - case 144: + case 140: + case 142: case 145: case 146: - case 142: + case 147: case 143: - case 170: + case 144: case 171: + case 172: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13368,7 +13572,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13424,7 +13628,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13438,7 +13642,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 125 : 127; + var syntaxKind = kind === 1 ? 126 : 128; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13467,13 +13671,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); } function getTypeListId(types) { switch (types.length) { @@ -13492,19 +13696,19 @@ var ts; return result; } } - function getWideningFlagsOfTypes(types) { + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13520,13 +13724,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 && n.typeName.kind === 66) { + if (n.kind === 149 && n.typeName.kind === 67) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13593,7 +13797,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 148 ? node.typeName : + var typeNameOrExpression = node.kind === 149 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13619,9 +13823,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211: case 212: - case 214: + case 213: + case 215: return declaration; } } @@ -13694,7 +13898,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -13720,20 +13924,68 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) { + return true; + } + if (source.flags & 524288 && target.flags & 80896) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -13756,25 +14008,21 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - function getUnionType(types, noSubtypeReduction) { + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -13782,25 +14030,11 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -13823,7 +14057,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -13859,45 +14093,45 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114: + case 115: return anyType; - case 127: - return stringType; - case 125: - return numberType; - case 117: - return booleanType; case 128: - return esSymbolType; - case 100: - return voidType; - case 8: - return getTypeFromStringLiteral(node); - case 148: - return getTypeFromTypeReference(node); - case 147: + return stringType; + case 126: + return numberType; + case 118: return booleanType; - case 185: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromTypeQueryNode(node); - case 153: - return getTypeFromArrayTypeNode(node); - case 154: - return getTypeFromTupleTypeNode(node); - case 155: - return getTypeFromUnionTypeNode(node); - case 156: - return getTypeFromIntersectionTypeNode(node); - case 157: - return getTypeFromTypeNode(node.type); + case 129: + return esSymbolType; + case 101: + return voidType; + case 9: + return getTypeFromStringLiteral(node); case 149: - case 150: + return getTypeFromTypeReference(node); + case 148: + return booleanType; + case 186: + return getTypeFromTypeReference(node); case 152: + return getTypeFromTypeQueryNode(node); + case 154: + return getTypeFromArrayTypeNode(node); + case 155: + return getTypeFromTupleTypeNode(node); + case 156: + return getTypeFromUnionTypeNode(node); + case 157: + return getTypeFromIntersectionTypeNode(node); + case 158: + return getTypeFromTypeNode(node.type); + case 150: + case 151: + case 153: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 66: - case 132: - var symbol = getSymbolInfo(node); + case 67: + case 133: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -13956,7 +14190,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -13965,6 +14199,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -14058,27 +14294,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170: case 171: + case 172: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 163: return ts.forEach(node.properties, isContextSensitive); - case 161: + case 162: return ts.forEach(node.elements, isContextSensitive); - case 179: + case 180: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178: - return node.operatorToken.kind === 50 && + case 179: + return node.operatorToken.kind === 51 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242: + case 243: return isContextSensitive(node.initializer); + case 141: case 140: - case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 169: + case 170: return isContextSensitive(node.expression); } return false; @@ -14152,99 +14388,135 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source === target) return -1; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1; - if (source === undefinedType) + if (source === numberType && target.flags & 128) return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; } + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 && target.flags & 512) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; @@ -14315,30 +14587,17 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1; - if (!(constraint && constraint.flags & 512)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0; } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); } function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { @@ -14515,22 +14774,12 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -14554,6 +14803,30 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -14642,7 +14915,7 @@ var ts; } var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); if (!related) { return 0; } @@ -14655,7 +14928,7 @@ var ts; return indexTypesIdenticalTo(0, source, target); } var targetType = getIndexTypeOfType(target, 0); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceType = getIndexTypeOfType(source, 0); if (!sourceType) { if (reportErrors) { @@ -14679,7 +14952,7 @@ var ts; return indexTypesIdenticalTo(1, source, target); } var targetType = getIndexTypeOfType(target, 1); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceStringType = getIndexTypeOfType(source, 0); var sourceNumberType = getIndexTypeOfType(source, 1); if (!(sourceStringType || sourceNumberType)) { @@ -14756,14 +15029,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } } var result = -1; if (source.typeParameters && target.typeParameters) { @@ -14783,16 +15060,18 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -14847,6 +15126,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -14874,7 +15170,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } @@ -14918,7 +15214,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -14932,22 +15228,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 139: case 138: - case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135: + case 136: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: - case 170: + case 144: case 171: + case 172: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14960,7 +15256,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -14996,7 +15292,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -15020,10 +15318,10 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -15047,6 +15345,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; @@ -15190,10 +15495,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 151: + case 152: return true; - case 66: - case 132: + case 67: + case 133: node = node.parent; continue; default: @@ -15233,12 +15538,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { + if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { var n = node.left; - while (n.kind === 169) { + while (n.kind === 170) { n = n.expression; } - if (n.kind === 66 && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15252,82 +15557,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178: + case 179: return isAssignedInBinaryExpression(node); - case 208: - case 160: - return isAssignedInVariableDeclaration(node); - case 158: - case 159: + case 209: case 161: + return isAssignedInVariableDeclaration(node); + case 159: + case 160: case 162: case 163: case 164: case 165: case 166: - case 168: - case 186: + case 167: case 169: - case 176: - case 172: - case 175: - case 173: - case 174: + case 187: + case 170: case 177: - case 181: - case 179: + case 173: + case 176: + case 174: + case 175: + case 178: case 182: - case 189: + case 180: + case 183: case 190: - case 192: + case 191: case 193: case 194: case 195: case 196: case 197: case 198: - case 201: + case 199: case 202: case 203: - case 238: - case 239: case 204: + case 239: + case 240: case 205: case 206: - case 241: - case 230: + case 207: + case 242: case 231: - case 235: - case 236: case 232: + case 236: case 237: + case 233: + case 238: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - return getNarrowedTypeOfSymbol(symbol, node); - } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { @@ -15337,34 +15620,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193: + case 194: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 179: + case 180: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 178: + case 179: if (child === node.right) { - if (node.operatorToken.kind === 49) { + if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 50) { + else if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, false); } } break; - case 245: - case 215: - case 210: - case 140: - case 139: - case 142: - case 143: + case 246: + case 216: + case 211: case 141: + case 140: + case 143: + case 144: + case 142: break loop; } if (narrowedType !== type) { @@ -15378,21 +15661,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 173 || expr.right.kind !== 8) { + if (expr.left.kind !== 174 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32) { + if (expr.operatorToken.kind === 33) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -15429,7 +15712,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15462,11 +15745,14 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } if (originalType.flags & 16384) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; } return originalType; } @@ -15490,27 +15776,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165: + case 166: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169: + case 170: return narrowType(type, expr.expression, assumeTrue); - case 178: + case 179: var operator = expr.operatorToken.kind; - if (operator === 31 || operator === 32) { + if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88) { + else if (operator === 89) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176: - if (expr.operator === 47) { + case 177: + if (expr.operator === 48) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15522,7 +15808,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171) { + if (container.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15553,15 +15839,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 241) { + symbol.valueDeclaration.parent.kind === 242) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 209) { + while (container.kind !== 210) { container = container.parent; } container = container.parent; - if (container.kind === 190) { + if (container.kind === 191) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15579,7 +15865,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 138 || container.kind === 141) { + if (container.kind === 139 || container.kind === 142) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15590,29 +15876,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 171) { + if (container.kind === 172) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 215: + case 216: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 214: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 141: + case 142: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 139: case 138: - case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133: + case 134: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15627,86 +15913,92 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135) { + if (n.kind === 136) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 172) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; - if (isCallExpression) { - canUseSuperExpression = container.kind === 141; + if (!canUseSuperExpression) { + if (container && container.kind === 134) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + return container.kind === 142; } else { - needToCaptureLexicalThis = false; - while (container && container.kind === 171) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143; + container.kind === 143 || + container.kind === 144; } else { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143 || - container.kind === 138 || - container.kind === 137 || - container.kind === 141; + container.kind === 143 || + container.kind === 144 || + container.kind === 139 || + container.kind === 138 || + container.kind === 142; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 512; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256; - returnType = baseClassType; - } - if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } function getContextuallyTypedParameterType(parameter) { if (isFunctionExpressionOrArrowFunction(parameter.parent)) { @@ -15735,7 +16027,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15768,7 +16060,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 && node.parent.initializer === node) { + if (node.parent.kind === 136 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15777,8 +16069,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 141 || - functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { + functionDecl.kind === 142 || + functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15797,7 +16089,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167) { + if (template.parent.kind === 168) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15805,12 +16097,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 && operator <= 65) { + if (operator >= 55 && operator <= 66) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50) { + else if (operator === 51) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15897,7 +16189,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 235) { + if (expr.parent.kind === 236) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15907,7 +16199,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236) { + if (expr.kind === 237) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15925,38 +16217,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 160: - return getContextualTypeForInitializerExpression(node); - case 171: - case 201: - return getContextualTypeForReturnExpression(node); - case 181: - return getContextualTypeForYieldOperand(parent); - case 165: - case 166: - return getContextualTypeForArgument(parent, node); - case 168: - case 186: - return getTypeFromTypeNode(parent.type); - case 178: - return getContextualTypeForBinaryOperand(node); - case 242: - return getContextualTypeForObjectLiteralElement(parent); case 161: - return getContextualTypeForElementExpression(node); - case 179: - return getContextualTypeForConditionalOperand(node); - case 187: - ts.Debug.assert(parent.parent.kind === 180); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 172: + case 202: + return getContextualTypeForReturnExpression(node); + case 182: + return getContextualTypeForYieldOperand(parent); + case 166: + case 167: + return getContextualTypeForArgument(parent, node); case 169: + case 187: + return getTypeFromTypeNode(parent.type); + case 179: + return getContextualTypeForBinaryOperand(node); + case 243: + return getContextualTypeForObjectLiteralElement(parent); + case 162: + return getContextualTypeForElementExpression(node); + case 180: + return getContextualTypeForConditionalOperand(node); + case 188: + ts.Debug.assert(parent.parent.kind === 181); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 170: return getContextualType(parent); + case 238: case 237: - case 236: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15971,7 +16263,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 || node.kind === 171; + return node.kind === 171 || node.kind === 172; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15979,7 +16271,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15993,16 +16285,12 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - if (signatureList && - getSignaturesOfStructuredType(current, 0).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { return undefined; } else { @@ -16019,17 +16307,17 @@ var ts; return result; } function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { + if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { return true; } - if (parent.kind === 242) { + if (parent.kind === 243) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161) { + if (parent.kind === 162) { return isAssignmentTarget(parent); } return false; @@ -16048,7 +16336,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182) { + if (inDestructuringPattern && e.kind === 183) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -16060,7 +16348,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182; + hasSpreadElement = hasSpreadElement || e.kind === 183; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -16071,7 +16359,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -16086,7 +16374,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -16104,18 +16392,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 === 242 || - memberDecl.kind === 243 || + if (memberDecl.kind === 243 || + memberDecl.kind === 244 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242) { + if (memberDecl.kind === 243) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140) { + else if (memberDecl.kind === 141) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243); + ts.Debug.assert(memberDecl.kind === 244); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -16130,7 +16418,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); + ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16141,7 +16429,7 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 2097152 | (typeFlags & 1048576); + result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -16170,31 +16458,34 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66) { + if (lhs.kind === 67) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - checkJsxOpeningLikeElement(node.openingElement); + else { + getJsxElementTagSymbol(node.closingElement); + } for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237: + case 238: checkJsxExpression(child); break; - case 230: + case 231: checkJsxElement(child); break; - case 231: + case 232: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 233); + ts.Debug.assert(child.kind === 234); } } return jsxElementType || anyType; @@ -16203,7 +16494,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -16218,9 +16509,17 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -16283,7 +16582,7 @@ var ts; links.jsxFlags |= 2; return intrinsicElementsType.symbol; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -16293,26 +16592,26 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; - if (node.tagName.kind === 66) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } + var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4)) { - return undefined; - } + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { return anyType; @@ -16326,14 +16625,10 @@ var ts; signatures = getSignaturesOfType(valueType, 0); if (signatures.length === 0) { error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); @@ -16368,7 +16663,7 @@ var ts; if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -16436,7 +16731,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -16445,11 +16740,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235) { + if (node.attributes[i].kind === 236) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236); + ts.Debug.assert(node.attributes[i].kind === 237); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16475,7 +16770,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138; + return s.valueDeclaration ? s.valueDeclaration.kind : 139; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16483,11 +16778,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92) { - var errorNode = node.kind === 163 ? + if (left.kind === 93) { + var errorNode = node.kind === 164 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 140) { + if (getDeclarationKindFromSymbol(prop) !== 141) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16508,7 +16803,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16553,7 +16848,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 + var left = node.kind === 164 ? node.expression : node.left; var type = checkExpression(left); @@ -16568,7 +16863,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 && node.parent.expression === node) { + if (node.parent.kind === 167 && 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); @@ -16586,7 +16881,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -16604,7 +16899,7 @@ var ts; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -16624,7 +16919,7 @@ var ts; return unknownType; } function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 || indexArgumentExpression.kind === 7) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { @@ -16640,7 +16935,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 4194304) === 0) { + if ((expressionType.flags & 16777216) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -16664,10 +16959,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167) { + if (node.kind === 168) { checkExpression(node.template); } - else if (node.kind !== 136) { + else if (node.kind !== 137) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16689,19 +16984,19 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -16718,7 +17013,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182) { + if (arg && arg.kind === 183) { return i; } } @@ -16730,11 +17025,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167) { + if (node.kind === 168) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180) { + if (tagExpression.template.kind === 181) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16742,11 +17037,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10); + ts.Debug.assert(templateLiteral.kind === 11); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136) { + else if (node.kind === 137) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16754,7 +17049,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 166); + ts.Debug.assert(callExpression.kind === 167); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16807,7 +17102,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16854,11 +17149,11 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { - argType = arg.kind === 8 && !reportErrors + argType = arg.kind === 9 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -16873,16 +17168,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 167) { + if (node.kind === 168) { var template = node.template; args = [undefined]; - if (template.kind === 180) { + if (template.kind === 181) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136) { + else if (node.kind === 137) { return undefined; } else { @@ -16891,18 +17186,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136) { + if (node.kind === 137) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return 1; - case 138: + case 139: return 2; - case 140: - case 142: + case 141: case 143: + case 144: return signature.parameters.length >= 3 ? 3 : 2; - case 135: + case 136: return 3; } } @@ -16912,20 +17207,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 211: - case 183: + case 212: + case 184: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16934,27 +17229,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { return anyType; } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: var element = node; switch (element.name.kind) { - case 66: - case 7: + case 67: case 8: + case 9: return getStringLiteralType(element.name); - case 133: + case 134: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304)) { + if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; } else { @@ -16971,17 +17266,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135: + case 136: return numberType; - case 138: + case 139: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140: - case 142: + case 141: case 143: + case 144: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -17003,26 +17298,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 136 || - (argIndex === 0 && node.kind === 167)) { + if (node.kind === 137 || + (argIndex === 0 && node.kind === 168)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return node.expression; } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return node.template; } else { @@ -17030,12 +17325,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167; - var isDecorator = node.kind === 136; + var isTaggedTemplate = node.kind === 168; + var isDecorator = node.kind === 137; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 92) { + if (node.expression.kind !== 93) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17098,6 +17393,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -17170,7 +17468,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17215,7 +17513,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -17259,16 +17557,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135: + case 136: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140: - case 142: + case 141: case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17296,16 +17594,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165) { + if (node.kind === 166) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166) { + else if (node.kind === 167) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 168) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136) { + else if (node.kind === 137) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17317,15 +17615,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { return voidType; } - if (node.kind === 166) { + if (node.kind === 167) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 && - declaration.kind !== 145 && - declaration.kind !== 150) { + declaration.kind !== 142 && + declaration.kind !== 146 && + declaration.kind !== 151) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -17338,7 +17636,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -17357,13 +17655,22 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -17381,7 +17688,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189) { + if (func.body.kind !== 190) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17485,7 +17792,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205); + return (body.statements.length === 1) && (body.statements[0].kind === 206); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17494,7 +17801,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { return; } var bodyBlock = func.body; @@ -17507,9 +17814,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 !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170) { + if (!hasGrammarError && node.kind === 171) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17521,33 +17828,38 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 1024)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 1024)) { + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { + if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17564,7 +17876,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189) { + if (node.body.kind === 190) { checkSourceElement(node.body); } else { @@ -17596,17 +17908,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 66: { + case 67: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 163: { + case 164: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 164: + case 165: return true; - case 169: + case 170: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17614,22 +17926,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66: - case 163: { + case 67: + case 164: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 164: { + case 165: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8) { + if (symbol && index && index.kind === 9) { var name_13 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 169: + case 170: return isConstVariableReference(n.expression); default: return false; @@ -17672,17 +17984,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34: case 35: - case 48: - if (someConstituentTypeHasKind(operandType, 4194304)) { + case 36: + case 49: + if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47: + case 48: return booleanType; - case 39: case 40: + case 41: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17738,7 +18050,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 4194814)) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -17747,7 +18059,7 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { @@ -17759,7 +18071,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var name_14 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17784,8 +18096,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17810,7 +18122,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { + if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17823,14 +18135,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161) { + if (target.kind === 162) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17844,32 +18156,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { + if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36: - case 57: case 37: case 58: case 38: case 59: - case 35: - case 56: - case 41: + case 39: case 60: + case 36: + case 57: case 42: case 61: case 43: case 62: - case 45: - case 64: - case 46: - case 65: case 44: case 63: + case 46: + case 65: + case 47: + case 66: + case 45: + case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17888,8 +18200,8 @@ var ts; } } return numberType; - case 34: - case 55: + case 35: + case 56: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17913,42 +18225,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55) { + if (operator === 56) { checkAssignmentOperator(resultType); } return resultType; - case 24: - case 26: + case 25: case 27: case 28: + case 29: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 29: case 30: case 31: case 32: + case 33: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88: + case 89: return checkInstanceOfExpression(node, leftType, rightType); - case 87: + case 88: return checkInExpression(node, leftType, rightType); - case 49: - return rightType; case 50: - return getUnionType([leftType, rightType]); - case 54: - checkAssignmentOperator(rightType); return rightType; - case 23: + case 51: + return getUnionType([leftType, rightType]); + case 55: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : - someConstituentTypeHasKind(rightType, 4194304) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : + someConstituentTypeHasKind(rightType, 16777216) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17958,21 +18270,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 46: + case 65: + return 51; + case 47: + case 66: + return 33; case 45: case 64: return 50; - case 46: - case 65: - return 32; - case 44: - case 63: - return 49; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 && operator <= 65) { + if (produceDiagnostics && operator >= 55 && operator <= 66) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -18056,21 +18368,21 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -18086,7 +18398,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -18094,9 +18406,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 163 && node.parent.expression === node) || - (node.parent.kind === 164 && node.parent.expression === node) || - ((node.kind === 66 || node.kind === 132) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 && node.parent.expression === node) || + (node.parent.kind === 165 && node.parent.expression === node) || + ((node.kind === 67 || node.kind === 133) && 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); } @@ -18109,78 +18421,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66: + case 67: return checkIdentifier(node); - case 94: + case 95: return checkThisExpression(node); - case 92: + case 93: return checkSuperExpression(node); - case 90: + case 91: return nullType; - case 96: - case 81: + case 97: + case 82: return booleanType; - case 7: - return checkNumericLiteral(node); - case 180: - return checkTemplateExpression(node); case 8: - case 10: - return stringType; - case 9: - return globalRegExpType; - case 161: - return checkArrayLiteral(node, contextualMapper); - case 162: - return checkObjectLiteral(node, contextualMapper); - case 163: - return checkPropertyAccessExpression(node); - case 164: - return checkIndexedAccess(node); - case 165: - case 166: - return checkCallExpression(node); - case 167: - return checkTaggedTemplateExpression(node); - case 169: - return checkExpression(node.expression, contextualMapper); - case 183: - return checkClassExpression(node); - case 170: - case 171: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173: - return checkTypeOfExpression(node); - case 168: - case 186: - return checkAssertion(node); - case 172: - return checkDeleteExpression(node); - case 174: - return checkVoidExpression(node); - case 175: - return checkAwaitExpression(node); - case 176: - return checkPrefixUnaryExpression(node); - case 177: - return checkPostfixUnaryExpression(node); - case 178: - return checkBinaryExpression(node, contextualMapper); - case 179: - return checkConditionalExpression(node, contextualMapper); - case 182: - return checkSpreadElementExpression(node, contextualMapper); - case 184: - return undefinedType; + return checkNumericLiteral(node); case 181: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 162: + return checkArrayLiteral(node, contextualMapper); + case 163: + return checkObjectLiteral(node, contextualMapper); + case 164: + return checkPropertyAccessExpression(node); + case 165: + return checkIndexedAccess(node); + case 166: + case 167: + return checkCallExpression(node); + case 168: + return checkTaggedTemplateExpression(node); + case 170: + return checkExpression(node.expression, contextualMapper); + case 184: + return checkClassExpression(node); + case 171: + case 172: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 174: + return checkTypeOfExpression(node); + case 169: + case 187: + return checkAssertion(node); + case 173: + return checkDeleteExpression(node); + case 175: + return checkVoidExpression(node); + case 176: + return checkAwaitExpression(node); + case 177: + return checkPrefixUnaryExpression(node); + case 178: + return checkPostfixUnaryExpression(node); + case 179: + return checkBinaryExpression(node, contextualMapper); + case 180: + return checkConditionalExpression(node, contextualMapper); + case 183: + return checkSpreadElementExpression(node, contextualMapper); + case 185: + return undefinedType; + case 182: return checkYieldExpression(node); - case 237: + case 238: return checkJsxExpression(node); - case 230: - return checkJsxElement(node); case 231: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 232: + return checkJsxSelfClosingElement(node); + case 233: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18205,7 +18517,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18220,15 +18532,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 || - node.kind === 210 || - node.kind === 170; + return node.kind === 141 || + node.kind === 211 || + node.kind === 171; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 && + if (param.name.kind === 67 && param.name.text === parameter.text) { return i; } @@ -18238,30 +18550,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { + case 172: + case 145: + case 211: case 171: - case 144: - case 210: - case 170: - case 149: + case 150: + case 141: case 140: - case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 146) { + if (node.kind === 147) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || - node.kind === 144 || node.kind === 141 || - node.kind === 145) { + else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || + node.kind === 145 || node.kind === 142 || + node.kind === 146) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147) { + if (node.type.kind === 148) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18270,7 +18582,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -18280,19 +18592,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 || - param.name.kind === 159) { + if (param.name.kind === 159 || + param.name.kind === 160) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 && + if (element.name.kind === 67 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 || - element.name.kind === 158) { + else if (element.name.kind === 160 || + element.name.kind === 159) { checkBindingPattern(element.name); } } @@ -18316,10 +18628,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145: + case 146: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144: + case 145: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18341,7 +18653,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212) { + if (node.kind === 213) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18356,7 +18668,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127: + case 128: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18364,7 +18676,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18404,48 +18716,69 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 && n.expression.kind === 92; + return n.kind === 166 && n.expression.kind === 93; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170: - case 210: - case 171: - case 162: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94) { + if (n.kind === 95) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 && n.kind !== 210) { + else if (n.kind !== 171 && n.kind !== 211) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 && + return n.kind === 139 && !(n.flags & 128) && !!n.initializer; } - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || 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 !== 192 || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { 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 { - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -18453,13 +18786,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142) { + if (node.kind === 143) { 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 === 142 ? 143 : 142; + var otherKind = node.kind === 143 ? 144 : 143; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18544,9 +18877,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); - var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); + var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18564,7 +18897,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18640,7 +18973,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 === 140 || node.kind === 139); + ts.Debug.assert(node.kind === 141 || node.kind === 140); 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); @@ -18672,11 +19005,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { + if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18755,35 +19088,50 @@ var ts; } var exportedDeclarationSpaces = 0; var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212: + case 213: return 2097152; - case 215: - return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 + case 216: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 211: - case 214: + case 212: + case 215: return 2097152 | 1048576; - case 218: + case 219: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18918,22 +19266,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211: + case 212: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135: + case 136: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140: - case 142: + case 141: case 143: + case 144: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18942,7 +19290,7 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 148) { + if (node && node.kind === 149) { var root = getFirstIdentifier(node.typeName); var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { @@ -18952,19 +19300,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138: + case 139: checkTypeNodeAsExpression(node.type); break; - case 135: + case 136: checkTypeNodeAsExpression(node.type); break; - case 140: - checkTypeNodeAsExpression(node.type); - break; - case 142: + case 141: checkTypeNodeAsExpression(node.type); break; case 143: + checkTypeNodeAsExpression(node.type); + break; + case 144: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18987,24 +19335,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 211: + case 212: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140: + case 141: checkParameterTypeAnnotationsAsExpressions(node); + case 144: case 143: - case 142: - case 138: - case 135: + case 139: + case 136: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135) { + if (node.kind === 136) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -19027,7 +19375,7 @@ var ts; } emitAwaiter = true; } - if (node.name && node.name.kind === 133) { + if (node.name && node.name.kind === 134) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -19062,11 +19410,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 189) { + if (node.kind === 190) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216) { + if (ts.isFunctionBlock(node) || node.kind === 217) { checkFunctionAndClassExpressionBodies(node); } } @@ -19084,19 +19432,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 || - node.kind === 137 || + if (node.kind === 139 || + node.kind === 138 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || - node.kind === 143) { + node.kind === 143 || + node.kind === 144) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19110,7 +19458,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 66; + var isDeclaration_1 = node.kind !== 67; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19131,7 +19479,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66; + var isDeclaration_2 = node.kind !== 67; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19144,11 +19492,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 245 && ts.isExternalModule(parent)) { + if (parent.kind === 246 && 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)); } } @@ -19159,7 +19507,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 208 && !node.initializer) { + if (node.kind === 209 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19169,15 +19517,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); - var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); + var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 189 && ts.isFunctionLike(container.parent) || + (container.kind === 190 && ts.isFunctionLike(container.parent) || + container.kind === 217 || container.kind === 216 || - container.kind === 215 || - container.kind === 245); + container.kind === 246); if (!namesShareScope) { var name_15 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); @@ -19187,16 +19535,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135) { + if (ts.getRootDeclaration(node).kind !== 136) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66) { + if (n.kind === 67) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135) { + if (referencedSymbol.valueDeclaration.kind === 136) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19216,7 +19564,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19225,7 +19573,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19253,9 +19601,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 138 && node.kind !== 137) { + if (node.kind !== 139 && node.kind !== 138) { checkExportsOnMergedDeclarations(node); - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19276,7 +19624,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 162) { + if (node.modifiers && node.parent.kind === 163) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19309,12 +19657,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209) { + if (node.initializer && node.initializer.kind === 210) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19329,13 +19677,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19350,7 +19698,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { 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); @@ -19360,7 +19708,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19522,7 +19870,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); + return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19540,10 +19888,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 143) { + if (func.kind === 144) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141) { + else if (func.kind === 142) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19576,7 +19924,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 239 && !hasDuplicateDefaultClause) { + if (clause.kind === 240 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19588,7 +19936,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238) { + if (produceDiagnostics && clause.kind === 239) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19605,7 +19953,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 && current.label.text === node.label.text) { + if (current.kind === 205 && 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; @@ -19631,7 +19979,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66) { + if (catchClause.variableDeclaration.name.kind !== 67) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19699,7 +20047,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19852,7 +20200,7 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } @@ -19893,7 +20241,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 || kind === 143; + return kind === 143 || kind === 144; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19959,7 +20307,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); 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); @@ -19977,7 +20325,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -20009,28 +20357,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -20041,22 +20373,42 @@ var ts; }); nodeLinks.flags |= 8192; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34: return value; - case 35: return -value; - case 48: return ~value; + case 35: return value_1; + case 36: return -value_1; + case 49: return ~value_1; } return undefined; - case 178: + case 179: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20066,39 +20418,39 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45: return left | right; - case 44: return left & right; - case 42: return left >> right; - case 43: return left >>> right; - case 41: return left << right; - case 46: return left ^ right; - case 36: return left * right; - case 37: return left / right; - case 34: return left + right; - case 35: return left - right; - case 38: return left % right; + case 46: return left | right; + case 45: return left & right; + case 43: return left >> right; + case 44: return left >>> right; + case 42: return left << right; + case 47: return left ^ right; + case 37: return left * right; + case 38: return left / right; + case 35: return left + right; + case 36: return left - right; + case 39: return left % right; } return undefined; - case 7: + case 8: return +e.text; - case 169: + case 170: return evalConstant(e.expression); - case 66: + case 67: + case 165: case 164: - case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66) { - enumType = currentType; + if (e.kind === 67) { + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164) { + if (e.kind === 165) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8) { + e.argumentExpression.kind !== 9) { return undefined; } expression = e.expression; @@ -20110,25 +20462,25 @@ var ts; } var current = expression; while (current) { - if (current.kind === 66) { + if (current.kind === 67) { break; } - else if (current.kind === 163) { + else if (current.kind === 164) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); - if (!(enumType.symbol && (enumType.symbol.flags & 384))) { + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -20137,6 +20489,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -20170,7 +20524,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 214) { + if (declaration.kind !== 215) { return false; } var enumDeclaration = declaration; @@ -20193,8 +20547,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 || - (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 || + (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20216,7 +20570,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 8; + var isAmbientExternalModule = node.name.kind === 9; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -20224,7 +20578,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -20245,7 +20599,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 211); + var mergedClass = ts.getDeclarationOfKind(symbol, 212); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20264,28 +20618,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132) { + if (node.kind === 133) { node = node.left; } - else if (node.kind === 163) { + else if (node.kind === 164) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66); + ts.Debug.assert(node.kind === 67); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 ? + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -20304,7 +20658,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 ? + var message = node.kind === 228 ? 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)); @@ -20330,7 +20684,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -20365,7 +20719,7 @@ var ts; } } else { - if (languageVersion >= 2) { + if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.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); } } @@ -20381,8 +20735,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20395,7 +20749,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { + if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20409,15 +20763,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 245 ? node.parent : node.parent.parent; - if (container.kind === 215 && container.name.kind === 66) { + var container = node.parent.kind === 246 ? node.parent : node.parent.parent; + if (container.kind === 216 && container.name.kind === 67) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { markExportAsReferenced(node); } else { @@ -20434,10 +20788,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245) { + if (node.kind === 246) { return node.statements; } - if (node.kind === 215 && node.body.kind === 216) { + if (node.kind === 216 && node.body.kind === 217) { return node.body.statements; } return emptyArray; @@ -20474,182 +20828,181 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134: - return checkTypeParameter(node); case 135: + return checkTypeParameter(node); + case 136: return checkParameter(node); + case 139: case 138: - case 137: return checkPropertyDeclaration(node); - case 149: case 150: - case 144: + case 151: case 145: - return checkSignatureDeclaration(node); case 146: return checkSignatureDeclaration(node); - case 140: - case 139: - return checkMethodDeclaration(node); - case 141: - return checkConstructorDeclaration(node); - case 142: - case 143: - return checkAccessorDeclaration(node); - case 148: - return checkTypeReferenceNode(node); case 147: + return checkSignatureDeclaration(node); + case 141: + case 140: + return checkMethodDeclaration(node); + case 142: + return checkConstructorDeclaration(node); + case 143: + case 144: + return checkAccessorDeclaration(node); + case 149: + return checkTypeReferenceNode(node); + case 148: return checkTypePredicate(node); - case 151: - return checkTypeQuery(node); case 152: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 153: - return checkArrayType(node); + return checkTypeLiteral(node); case 154: - return checkTupleType(node); + return checkArrayType(node); case 155: + return checkTupleType(node); case 156: - return checkUnionOrIntersectionType(node); case 157: + return checkUnionOrIntersectionType(node); + case 158: return checkSourceElement(node.type); - case 210: - return checkFunctionDeclaration(node); - case 189: - case 216: - return checkBlock(node); - case 190: - return checkVariableStatement(node); - case 192: - return checkExpressionStatement(node); - case 193: - return checkIfStatement(node); - case 194: - return checkDoStatement(node); - case 195: - return checkWhileStatement(node); - case 196: - return checkForStatement(node); - case 197: - return checkForInStatement(node); - case 198: - return checkForOfStatement(node); - case 199: - case 200: - return checkBreakOrContinueStatement(node); - case 201: - return checkReturnStatement(node); - case 202: - return checkWithStatement(node); - case 203: - return checkSwitchStatement(node); - case 204: - return checkLabeledStatement(node); - case 205: - return checkThrowStatement(node); - case 206: - return checkTryStatement(node); - case 208: - return checkVariableDeclaration(node); - case 160: - return checkBindingElement(node); case 211: - return checkClassDeclaration(node); - case 212: - return checkInterfaceDeclaration(node); - case 213: - return checkTypeAliasDeclaration(node); - case 214: - return checkEnumDeclaration(node); - case 215: - return checkModuleDeclaration(node); - case 219: - return checkImportDeclaration(node); - case 218: - return checkImportEqualsDeclaration(node); - case 225: - return checkExportDeclaration(node); - case 224: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 190: + case 217: + return checkBlock(node); case 191: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 193: + return checkExpressionStatement(node); + case 194: + return checkIfStatement(node); + case 195: + return checkDoStatement(node); + case 196: + return checkWhileStatement(node); + case 197: + return checkForStatement(node); + case 198: + return checkForInStatement(node); + case 199: + return checkForOfStatement(node); + case 200: + case 201: + return checkBreakOrContinueStatement(node); + case 202: + return checkReturnStatement(node); + case 203: + return checkWithStatement(node); + case 204: + return checkSwitchStatement(node); + case 205: + return checkLabeledStatement(node); + case 206: + return checkThrowStatement(node); case 207: + return checkTryStatement(node); + case 209: + return checkVariableDeclaration(node); + case 161: + return checkBindingElement(node); + case 212: + return checkClassDeclaration(node); + case 213: + return checkInterfaceDeclaration(node); + case 214: + return checkTypeAliasDeclaration(node); + case 215: + return checkEnumDeclaration(node); + case 216: + return checkModuleDeclaration(node); + case 220: + return checkImportDeclaration(node); + case 219: + return checkImportEqualsDeclaration(node); + case 226: + return checkExportDeclaration(node); + case 225: + return checkExportAssignment(node); + case 192: checkGrammarStatementInAmbientContext(node); return; - case 228: + case 208: + checkGrammarStatementInAmbientContext(node); + return; + case 229: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170: case 171: + case 172: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183: + case 184: ts.forEach(node.members, checkSourceElement); break; + case 141: case 140: - case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141: case 142: case 143: - case 210: + case 144: + case 211: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202: + case 203: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136: - case 135: - case 138: case 137: - case 158: + case 136: + case 139: + case 138: case 159: case 160: case 161: case 162: - case 242: case 163: + case 243: case 164: case 165: case 166: case 167: - case 180: - case 187: case 168: - case 186: + case 181: + case 188: case 169: - case 173: + case 187: + case 170: case 174: case 175: - case 172: case 176: + case 173: case 177: case 178: case 179: + case 180: + case 183: case 182: - case 181: - case 189: - case 216: case 190: - case 192: + case 217: + case 191: case 193: case 194: case 195: @@ -20659,27 +21012,28 @@ var ts; case 199: case 200: case 201: - case 203: - case 217: - case 238: - case 239: + case 202: case 204: + case 218: + case 239: + case 240: case 205: case 206: - case 241: - case 208: + case 207: + case 242: case 209: - case 211: - case 214: - case 244: - case 224: + case 210: + case 212: + case 215: case 245: - case 237: - case 230: + case 225: + case 246: + case 238: case 231: - case 235: - case 236: case 232: + case 236: + case 237: + case 233: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20757,7 +21111,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 && node.parent.statement === node) { + if (node.parent.kind === 203 && node.parent.statement === node) { return true; } node = node.parent; @@ -20779,34 +21133,37 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) { break; } - case 215: + case 216: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 214: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 183: + case 184: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 211: case 212: + case 213: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 170: + case 171: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -20830,42 +21187,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 && + return name.kind === 67 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134: - case 211: + case 135: case 212: case 213: case 214: + case 215: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132) { + while (node.parent && node.parent.kind === 133) { node = node.parent; } - return node.parent && node.parent.kind === 148; + return node.parent && node.parent.kind === 149; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163) { + while (node.parent && node.parent.kind === 164) { node = node.parent; } - return node.parent && node.parent.kind === 185; + return node.parent && node.parent.kind === 186; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132) { + while (nodeOnRightSide.parent.kind === 133) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218) { + if (nodeOnRightSide.parent.kind === 219) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20877,10 +21234,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224) { + if (entityName.parent.kind === 225) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 163) { + if (entityName.kind !== 164) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20889,29 +21246,31 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 ? 793056 : 1536; + var meaning = entityName.parent.kind === 186 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + else if ((entityName.parent.kind === 233) || + (entityName.parent.kind === 232) || + (entityName.parent.kind === 235)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 66) { + if (entityName.kind === 67) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163) { + else if (entityName.kind === 164) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132) { + else if (entityName.kind === 133) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20920,54 +21279,65 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 ? 793056 : 1536; + var meaning = entityName.parent.kind === 149 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235) { + else if (entityName.parent.kind === 236) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 148) { return resolveEntityName(entityName, 1); } return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { return undefined; } if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 && + node.parent.parent.kind === 159 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66: - case 163: - case 132: + case 67: + case 164: + case 133: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94: - case 92: + case 95: + case 93: var type = checkExpression(node); return type.symbol; - case 118: + case 119: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141) { + if (constructorDeclaration && constructorDeclaration.kind === 142) { return constructorDeclaration.parent.symbol; } return undefined; - case 8: + case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 || node.parent.kind === 225) && + ((node.parent.kind === 220 || node.parent.kind === 226) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - case 7: - if (node.parent.kind === 164 && node.parent.argumentExpression === node) { + case 8: + if (node.parent.kind === 165 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20981,7 +21351,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 243) { + if (location && location.kind === 244) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21004,7 +21374,7 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { @@ -21012,14 +21382,14 @@ var ts; return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -21078,11 +21448,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21095,11 +21465,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189: - case 217: - case 196: + case 190: + case 218: case 197: case 198: + case 199: return true; } return false; @@ -21125,22 +21495,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218: - case 220: + case 219: case 221: - case 223: - case 227: + case 222: + case 224: + case 228: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225: + case 226: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224: - return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225: + return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21151,7 +21521,10 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -21185,7 +21558,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244) { + if (node.kind === 245) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21199,13 +21572,14 @@ var ts; function isFunctionType(type) { return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(node) { - var symbol = resolveEntityName(node.typeName, 107455, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + var typeSymbol = resolveEntityName(typeName, 793056, true); + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -21227,7 +21601,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304)) { + else if (allConstituentTypesHaveKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -21269,13 +21643,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && 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 !== 241; + symbol.valueDeclaration.parent.kind !== 242; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -21315,7 +21689,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -21396,7 +21771,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 === 142 || node.kind === 143) { + else if (node.kind === 143 || node.kind === 144) { 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); @@ -21406,38 +21781,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142: case 143: - case 141: - case 138: - case 137: - case 140: + case 144: + case 142: case 139: - case 146: - case 215: + case 138: + case 141: + case 140: + case 147: + case 216: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 135: - break; - case 210: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && - node.parent.kind !== 216 && node.parent.kind !== 245) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 136: break; case 211: - case 212: - case 190: - case 213: - if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 212: + case 213: + case 191: case 214: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && - node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 215: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21452,14 +21827,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 110: case 109: case 108: - case 107: var text = void 0; - if (modifier.kind === 109) { + if (modifier.kind === 110) { text = "public"; } - else if (modifier.kind === 108) { + else if (modifier.kind === 109) { text = "protected"; lastProtected = modifier; } @@ -21476,11 +21851,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 107) { + if (modifier.kind === 108) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21489,17 +21864,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110: + case 111: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21508,7 +21883,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 79: + case 80: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21521,42 +21896,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 119: + case 120: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 112: + case 113: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211) { - if (node.kind !== 140) { + if (node.kind !== 212) { + if (node.kind !== 141) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + if (!(node.parent.kind === 212 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21568,14 +21943,14 @@ var ts; } flags |= 256; break; - case 115: + case 116: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21583,7 +21958,7 @@ var ts; break; } } - if (node.kind === 141) { + if (node.kind === 142) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21601,10 +21976,10 @@ var ts; } return; } - else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + else if ((node.kind === 220 || node.kind === 219) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21616,10 +21991,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140: - case 210: - case 170: + case 141: + case 211: case 171: + case 172: if (!node.asteriskToken) { return false; } @@ -21667,16 +22042,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -21686,7 +22059,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171) { + if (node.kind === 172) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21721,7 +22094,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 !== 127 && parameter.type.kind !== 125) { + if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21753,7 +22126,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184) { + if (arg.kind === 185) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21780,7 +22153,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21793,7 +22166,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21808,14 +22181,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21824,19 +22197,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 133) { + if (node.kind !== 134) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 || - node.kind === 170 || - node.kind === 140); + ts.Debug.assert(node.kind === 211 || + node.kind === 171 || + node.kind === 141); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21862,26 +22235,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_17 = prop.name; - if (prop.kind === 184 || - name_17.kind === 133) { + if (prop.kind === 185 || + name_17.kind === 134) { checkGrammarComputedPropertyName(name_17); continue; } var currentKind = void 0; - if (prop.kind === 242 || prop.kind === 243) { + if (prop.kind === 243 || prop.kind === 244) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7) { + if (name_17.kind === 8) { checkGrammarNumericLiteral(name_17); } currentKind = Property; } - else if (prop.kind === 140) { + else if (prop.kind === 141) { currentKind = Property; } - else if (prop.kind === 142) { + else if (prop.kind === 143) { currentKind = GetAccessor; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = SetAccesor; } else { @@ -21913,7 +22286,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236) { + if (attr.kind === 237) { continue; } var jsxAttr = attr; @@ -21925,7 +22298,7 @@ var ts; return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 && !initializer.expression) { + if (initializer && initializer.kind === 238 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21934,24 +22307,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209) { + if (forInOrOfStatement.initializer.kind === 210) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? 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 === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? 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 === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? 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); @@ -21974,10 +22347,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 && accessor.parameters.length) { + else if (kind === 143 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143) { + else if (kind === 144) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22002,7 +22375,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22012,7 +22385,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162) { + if (node.parent.kind === 163) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22031,22 +22404,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 === 212) { + else if (node.parent.kind === 213) { 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 === 152) { + else if (node.parent.kind === 153) { 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 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return true; - case 204: + case 205: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22058,9 +22431,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204: + case 205: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 199 + var isMisplacedContinueLabel = node.kind === 200 && !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); @@ -22068,8 +22441,8 @@ var ts; return false; } break; - case 203: - if (node.kind === 200 && !node.label) { + case 204: + if (node.kind === 201 && !node.label) { return false; } break; @@ -22082,13 +22455,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 + var message = node.kind === 201 ? 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 === 200 + var message = node.kind === 201 ? 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); @@ -22100,7 +22473,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 || node.name.kind === 158) { + if (node.name.kind === 160 || node.name.kind === 159) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22109,7 +22482,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { + if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22129,7 +22502,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66) { + if (name.kind === 67) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22138,7 +22511,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22155,15 +22528,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193: case 194: case 195: - case 202: case 196: + case 203: case 197: case 198: + case 199: return false; - case 204: + case 205: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22179,13 +22552,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176) { + if (expression.kind === 177) { var unaryExpression = expression; - if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; } } - if (expression.kind === 7) { + if (expression.kind === 8) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); } return false; @@ -22198,7 +22571,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 === 133) { + if (node.name.kind === 134) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -22241,7 +22614,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22261,12 +22634,12 @@ var ts; return true; } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { 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 === 152) { + else if (node.parent.kind === 153) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22276,11 +22649,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 212 || + if (node.kind === 213 || + node.kind === 220 || node.kind === 219 || - node.kind === 218 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22290,7 +22663,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 === 190) { + if (ts.isDeclaration(decl) || decl.kind === 191) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22309,7 +22682,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 === 189 || node.parent.kind === 216 || node.parent.kind === 245) { + if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { 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); @@ -22382,7 +22755,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219); + ts.Debug.assert(aliasEmitInfo.node.kind === 220); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22455,10 +22828,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208) { + if (declaration.kind === 209) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { + else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22469,7 +22842,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219) { + if (moduleElementEmitInfo.node.kind === 220) { moduleElementEmitInfo.isVisible = true; } else { @@ -22477,12 +22850,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22569,62 +22942,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 8: + case 126: + case 118: + case 129: + case 101: + case 9: return writeTextOfNode(currentSourceFile, type); - case 185: + case 186: return emitExpressionWithTypeArguments(type); - case 148: - return emitTypeReference(type); - case 151: - return emitTypeQuery(type); - case 153: - return emitArrayType(type); - case 154: - return emitTupleType(type); - case 155: - return emitUnionType(type); - case 156: - return emitIntersectionType(type); - case 157: - return emitParenType(type); case 149: - case 150: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 152: + return emitTypeQuery(type); + case 154: + return emitArrayType(type); + case 155: + return emitTupleType(type); + case 156: + return emitUnionType(type); + case 157: + return emitIntersectionType(type); + case 158: + return emitParenType(type); + case 150: + case 151: + return emitSignatureDeclarationWithJsDocComments(type); + case 153: return emitTypeLiteral(type); - case 66: + case 67: return emitEntityName(type); - case 132: + case 133: return emitEntityName(type); - case 147: + case 148: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66) { + if (entityName.kind === 67) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 ? entityName.left : entityName.expression; - var right = entityName.kind === 132 ? entityName.right : entityName.name; + var left = entityName.kind === 133 ? entityName.left : entityName.expression; + var right = entityName.kind === 133 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); + ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22700,7 +23073,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22718,7 +23091,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22736,10 +23109,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 || - (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 || + (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22748,7 +23121,7 @@ var ts; }); } else { - if (node.kind === 219) { + if (node.kind === 220) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22766,23 +23139,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210: - return writeFunctionDeclaration(node); - case 190: - return writeVariableStatement(node); - case 212: - return writeInterfaceDeclaration(node); case 211: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 191: + return writeVariableStatement(node); case 213: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 212: + return writeClassDeclaration(node); case 214: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 215: + return writeEnumDeclaration(node); + case 216: return writeModuleDeclaration(node); - case 218: - return writeImportEqualsDeclaration(node); case 219: + return writeImportEqualsDeclaration(node); + case 220: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22796,7 +23169,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22843,7 +23216,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22869,7 +23242,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22925,7 +23298,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216) { + while (node.body.kind !== 217) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22942,14 +23315,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -22986,7 +23363,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 && (node.parent.flags & 32); + return node.parent.kind === 141 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22996,15 +23373,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - (node.parent.parent && node.parent.parent.kind === 152)) { - ts.Debug.assert(node.parent.kind === 140 || - node.parent.kind === 139 || - node.parent.kind === 149 || + if (node.parent.kind === 150 || + node.parent.kind === 151 || + (node.parent.parent && node.parent.parent.kind === 153)) { + ts.Debug.assert(node.parent.kind === 141 || + node.parent.kind === 140 || node.parent.kind === 150 || - node.parent.kind === 144 || - node.parent.kind === 145); + node.parent.kind === 151 || + node.parent.kind === 145 || + node.parent.kind === 146); emitType(node.constraint); } else { @@ -23014,31 +23391,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 211: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 146: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 141: case 140: - case 139: 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 === 211) { + else if (node.parent.parent.kind === 212) { 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 210: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23068,7 +23445,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 211) { + if (node.parent.parent.kind === 212) { 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; @@ -23148,16 +23525,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { + if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23166,14 +23543,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208) { + if (node.kind === 209) { 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 === 138 || node.kind === 137) { + else if (node.kind === 139 || node.kind === 138) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23181,7 +23558,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 === 211) { + else if (node.parent.kind === 212) { 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 : @@ -23207,7 +23584,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { elements.push(element); } } @@ -23273,7 +23650,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23286,7 +23663,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 + return accessor.kind === 143 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23295,7 +23672,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143) { + if (accessorWithTypeAnnotation.kind === 144) { 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 : @@ -23341,17 +23718,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210) { + if (node.kind === 211) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140) { + else if (node.kind === 141) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210) { + if (node.kind === 211) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141) { + else if (node.kind === 142) { write("constructor"); } else { @@ -23368,11 +23745,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 145 || node.kind === 150) { + if (node.kind === 146 || node.kind === 151) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146) { + if (node.kind === 147) { write("["); } else { @@ -23381,20 +23758,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146) { + if (node.kind === 147) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { + var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 && !(node.flags & 32)) { + else if (node.kind !== 142 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23405,23 +23782,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145: + case 146: 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 144: + case 145: 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 146: + case 147: 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 141: case 140: - case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23429,7 +23806,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 === 211) { + else if (node.parent.kind === 212) { 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 : @@ -23442,7 +23819,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210: + case 211: 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 : @@ -23470,13 +23847,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - node.parent.parent.kind === 152) { + if (node.parent.kind === 150 || + node.parent.kind === 151 || + node.parent.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23492,22 +23869,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141: + case 142: 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 145: + case 146: 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 144: + case 145: 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 141: case 140: - case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23515,7 +23892,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 === 211) { + else if (node.parent.parent.kind === 212) { 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 : @@ -23527,7 +23904,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 210: + case 211: 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 : @@ -23538,12 +23915,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 158) { + if (bindingPattern.kind === 159) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159) { + else if (bindingPattern.kind === 160) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23562,21 +23939,20 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184) { + if (bindingElement.kind === 185) { write(" "); } - else if (bindingElement.kind === 160) { + else if (bindingElement.kind === 161) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66); + ts.Debug.assert(bindingElement.name.kind === 67); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23588,39 +23964,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210: - case 215: - case 218: - case 212: case 211: - case 213: - case 214: - return emitModuleElement(node, isModuleElementVisible(node)); - case 190: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 216: case 219: + case 213: + case 212: + case 214: + case 215: + return emitModuleElement(node, isModuleElementVisible(node)); + case 191: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 220: return emitModuleElement(node, !node.importClause); - case 225: + case 226: return emitExportDeclaration(node); + case 142: case 141: case 140: - case 139: return writeFunctionDeclaration(node); - case 145: - case 144: case 146: + case 145: + case 147: return emitSignatureDeclarationWithJsDocComments(node); - case 142: case 143: + case 144: return emitAccessorDeclaration(node); + case 139: case 138: - case 137: return emitPropertyDeclaration(node); - case 244: - return emitEnumMemberDeclaration(node); - case 224: - return emitExportAssignment(node); case 245: + return emitEnumMemberDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFile(node); } } @@ -23629,7 +24005,7 @@ var ts; ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } @@ -23685,17 +24061,17 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); @@ -23748,7 +24124,7 @@ var ts; var writeEmittedFiles = writeJavaScriptFile; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -23819,7 +24195,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? + var baseName = expr.kind === 9 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -23831,19 +24207,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66: + case 67: return makeUniqueName(node.text); + case 216: case 215: - case 214: return generateNameForModuleOrEnum(node); - case 219: - case 225: + case 220: + case 226: return generateNameForImportOrExportDeclaration(node); - case 210: case 211: - case 224: + case 212: + case 225: return generateNameForExportDefault(); - case 183: + case 184: return generateNameForClassExpression(); } } @@ -23897,7 +24273,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -23982,7 +24358,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_22 = node.name; - if (!name_22 || name_22.kind !== 133) { + if (!name_22 || name_22.kind !== 134) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -23999,18 +24375,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 210 || - node.kind === 170 || + else if (node.kind === 211 || + node.kind === 171 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || node.kind === 143 || - node.kind === 215 || - node.kind === 211 || - node.kind === 214) { + node.kind === 144 || + node.kind === 216 || + node.kind === 212 || + node.kind === 215) { if (node.name) { var name_23 = node.name; - scopeName = name_23.kind === 133 + scopeName = name_23.kind === 134 ? ts.getTextOfNode(name_23) : node.name.text; } @@ -24109,7 +24485,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245) { + if (node.kind !== 246) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -24120,8 +24496,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -24133,7 +24512,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66); + var result = ts.createSynthesizedNode(67); result.text = makeTempVariableName(flags); return result; } @@ -24243,7 +24622,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -24269,7 +24650,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 && text.length > 1) { + if (node.kind === 8 && text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: @@ -24282,7 +24663,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -24294,23 +24675,23 @@ var ts; } function getLiteralText(node) { if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } if (node.parent) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); } switch (node.kind) { - case 8: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10: - return getQuotedEscapedLiteralText('`', node.text, '`'); + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); case 11: - return getQuotedEscapedLiteralText('`', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText('}', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 13: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -24320,15 +24701,15 @@ var ts; } function emitDownlevelRawTemplateLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 10 || node.kind === 13; + var isLast = node.kind === 11 || node.kind === 14; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10) { + if (node.template.kind === 11) { literalEmitter(node.template); } else { @@ -24354,11 +24735,11 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 180) { + if (node.template.kind === 181) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 - && templateSpan.expression.operatorToken.kind === 23; + var needsParens = templateSpan.expression.kind === 179 + && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -24381,7 +24762,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 169 + var needsParens = templateSpan.expression.kind !== 170 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -24414,11 +24795,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165: case 166: - return parent.expression === template; case 167: - case 169: + return parent.expression === template; + case 168: + case 170: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24426,20 +24807,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 178: + case 179: switch (expression.operatorToken.kind) { - case 36: case 37: case 38: + case 39: return 1; - case 34: case 35: + case 36: return 0; default: return -1; } - case 181: - case 179: + case 182: + case 180: return -1; default: return 1; @@ -24452,10 +24833,10 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 66 && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24463,9 +24844,9 @@ var ts; } function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24491,36 +24872,36 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236) { - if (i_2 === 0) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235); + ts.Debug.assert(attrs[i_1].kind === 236); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -24540,15 +24921,15 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 237 && !(children[i].expression)) { + if (children[i].kind === 238 && !(children[i].expression)) { continue; } - if (children[i].kind === 233) { + if (children[i].kind === 234) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -24560,11 +24941,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxElement(node); } } @@ -24584,11 +24965,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236) { + if (attribs[i].kind === 237) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235); + ts.Debug.assert(attribs[i].kind === 236); emitJsxAttribute(attribs[i]); } } @@ -24596,11 +24977,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231)) { + if (node.attributes.length > 0 || (node.kind === 232)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231) { + if (node.kind === 232) { write("/>"); } else { @@ -24619,20 +25000,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160); - if (node.kind === 8) { + ts.Debug.assert(node.kind !== 161); + if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 133) { + else if (node.kind === 134) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -24651,7 +25032,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24663,58 +25044,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161: - case 178: - case 165: - case 238: - case 133: + case 162: case 179: - case 136: - case 172: - case 194: - case 164: - case 224: - case 192: - case 185: - case 196: + case 166: + case 239: + case 134: + case 180: + case 137: + case 173: + case 195: + case 165: + case 225: + case 193: + case 186: case 197: case 198: - case 193: - case 231: + case 199: + case 194: case 232: - case 166: - case 169: - case 177: - case 176: - case 201: - case 243: - case 182: - case 203: + case 233: + case 237: + case 238: case 167: - case 187: - case 205: - case 168: - case 173: - case 174: - case 195: - case 202: - case 181: - return true; - case 160: - case 244: - case 135: - case 242: - case 138: - case 208: - return parent.initializer === node; - case 163: - return parent.expression === node; - case 171: case 170: + case 178: + case 177: + case 202: + case 244: + case 183: + case 204: + case 168: + case 188: + case 206: + case 169: + case 174: + case 175: + case 196: + case 203: + case 182: + return true; + case 161: + case 245: + case 136: + case 243: + case 139: + case 209: + return parent.initializer === node; + case 164: + return parent.expression === node; + case 172: + case 171: return parent.body === node; - case 218: + case 219: return parent.moduleReference === node; - case 132: + case 133: return parent.left === node; } return false; @@ -24726,7 +25109,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245) { + if (container.kind === 246) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -24739,12 +25122,12 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220) { + if (declaration.kind === 221) { write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? '["default"]' : ".default"); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223) { + else if (declaration.kind === 224) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); @@ -24761,13 +25144,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160: - case 211: - case 214: - case 208: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161: + case 212: + case 215: + case 209: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -24841,7 +25224,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24855,7 +25238,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24863,22 +25246,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 && node.parent.condition === node) { + else if (node.parent.kind === 180 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66: - case 161: - case 163: + case 67: + case 162: case 164: case 165: - case 169: + case 166: + case 170: return false; } return true; @@ -24895,17 +25278,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182) { + if (e.kind === 183) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182) { + while (i < length && elements[i].kind !== 183) { i++; } write("["); @@ -24928,7 +25311,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24989,7 +25372,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 || property.kind === 143) { + if (property.kind === 143 || property.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -25040,13 +25423,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242) { + if (property.kind === 243) { emit(property.initializer); } - else if (property.kind === 243) { + else if (property.kind === 244) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140) { + else if (property.kind === 141) { emitFunctionDeclaration(property); } else { @@ -25078,7 +25461,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 === 133) { + if (properties[i].name.kind === 134) { numInitialNonComputedProperties = i; break; } @@ -25092,35 +25475,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178, startsOnNewLine); + var result = ts.createSynthesizedNode(179, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20); + result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(165); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 168 || expr.kind === 186) { + while (expr.kind === 169 || expr.kind === 187) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 && - expr.kind !== 7) { + expr.kind !== 167 && + expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(169); + var node = ts.createSynthesizedNode(170); node.expression = expr; return node; } @@ -25142,11 +25525,12 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245; + return container && container.kind !== 246; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -25156,20 +25540,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 || node.kind === 165 + ? resolver.getConstantValue(node) + : undefined; + } function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); @@ -25192,9 +25581,15 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -25212,7 +25607,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66) { + if (node.left.kind === 67) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -25228,11 +25623,11 @@ var ts; emitEntityNameAsExpression(node.left, false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66: + case 67: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -25240,7 +25635,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -25255,16 +25650,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182; }); + return ts.forEach(elements, function (e) { return e.kind === 183; }); } function skipParentheses(node) { - while (node.kind === 169 || node.kind === 168 || node.kind === 186) { + while (node.kind === 170 || node.kind === 169 || node.kind === 187) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 || node.kind === 94 || node.kind === 92) { + if (node.kind === 67 || node.kind === 95 || node.kind === 93) { emit(node); return node; } @@ -25279,18 +25674,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163) { + if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164) { + else if (expr.kind === 165) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92) { + else if (expr.kind === 93) { target = expr; write("_super"); } @@ -25299,7 +25694,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -25319,13 +25714,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; + superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; } if (superCall && languageVersion < 2) { write(".call("); @@ -25376,20 +25771,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { - if (node.expression.kind === 168 || node.expression.kind === 186) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { + if (node.expression.kind === 169 || node.expression.kind === 187) { var operand = node.expression.expression; - while (operand.kind === 168 || operand.kind === 186) { + while (operand.kind === 169 || operand.kind === 187) { operand = operand.expression; } - if (operand.kind !== 176 && + if (operand.kind !== 177 && + operand.kind !== 175 && operand.kind !== 174 && operand.kind !== 173 && - operand.kind !== 172 && - operand.kind !== 177 && - operand.kind !== 166 && - !(operand.kind === 165 && node.parent.kind === 166) && - !(operand.kind === 170 && node.parent.kind === 165)) { + operand.kind !== 178 && + operand.kind !== 167 && + !(operand.kind === 166 && node.parent.kind === 167) && + !(operand.kind === 171 && node.parent.kind === 166)) { emit(operand); return; } @@ -25400,25 +25795,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75)); + write(ts.tokenToString(76)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25432,12 +25827,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 176) { + if (node.operand.kind === 177) { var operand = node.operand; - if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } - else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { write(" "); } } @@ -25454,7 +25849,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39) { + if (node.operator === 40) { write(") - 1)"); } else { @@ -25475,10 +25870,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245) { + if (current.kind === 246) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216) { + else if (ts.isFunctionLike(current) || current.kind === 217) { return false; } else { @@ -25487,13 +25882,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 54 && - (node.left.kind === 162 || node.left.kind === 161)) { - emitDestructuring(node, node.parent.kind === 192); + if (languageVersion < 2 && node.operatorToken.kind === 55 && + (node.left.kind === 163 || node.left.kind === 162)) { + emitDestructuring(node, node.parent.kind === 193); } else { - var exportChanged = node.operatorToken.kind >= 54 && - node.operatorToken.kind <= 65 && + var exportChanged = node.operatorToken.kind >= 55 && + node.operatorToken.kind <= 66 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -25501,7 +25896,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -25536,36 +25931,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189) { + if (node && node.kind === 190) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14, node.pos); + emitToken(15, node.pos); write(" "); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); return; } - emitToken(14, node.pos); + emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216) { - ts.Debug.assert(node.parent.kind === 215); + if (node.kind === 217) { + ts.Debug.assert(node.parent.kind === 216); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216) { + if (node.kind === 217) { emitTempDeclarations(true); } decreaseIndent(); writeLine(); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189) { + if (node.kind === 190) { write(" "); emit(node); } @@ -25577,20 +25972,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171); + emitParenthesizedIf(node.expression, node.expression.kind === 172); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85, node.pos); + var endPos = emitToken(86, node.pos); write(" "); - endPos = emitToken(16, endPos); + endPos = emitToken(17, endPos); emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77, node.thenStatement.end); - if (node.elseStatement.kind === 193) { + emitToken(78, node.thenStatement.end); + if (node.elseStatement.kind === 194) { write(" "); emit(node.elseStatement); } @@ -25602,7 +25997,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { write(" "); } else { @@ -25622,13 +26017,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 99; + var tokenKind = 100; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 105; + tokenKind = 106; } else if (ts.isConst(decl)) { - tokenKind = 71; + tokenKind = 72; } } if (startPos !== undefined) { @@ -25637,13 +26032,13 @@ var ts; } else { switch (tokenKind) { - case 99: + case 100: write("var "); break; - case 105: + case 106: write("let "); break; - case 71: + case 72: write("const "); break; } @@ -25668,10 +26063,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 210) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -25692,13 +26087,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 198) { + if (languageVersion < 2 && node.kind === 199) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer.kind === 210) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -25708,14 +26103,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197) { + if (node.kind === 198) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -25739,10 +26134,10 @@ var ts; // 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(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 66; + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 67; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -25762,7 +26157,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25770,13 +26165,13 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25785,7 +26180,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25797,17 +26192,17 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); - if (node.initializer.kind === 161 || node.initializer.kind === 162) { + var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); + if (node.initializer.kind === 162 || node.initializer.kind === 163) { emitDestructuring(assignmentExpression, true, undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { emitLines(node.statement.statements); } else { @@ -25819,12 +26214,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 ? 67 : 72, node.pos); + emitToken(node.kind === 201 ? 68 : 73, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91, node.pos); + emitToken(92, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -25835,21 +26230,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93, node.pos); + var endPos = emitToken(94, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.expression); - endPos = emitToken(17, node.expression.end); + endPos = emitToken(18, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14, startPos); + emitToken(15, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15, node.clauses.end); + emitToken(16, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -25864,7 +26259,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238) { + if (node.kind === 239) { write("case "); emit(node.expression); write(":"); @@ -25899,16 +26294,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69, node.pos); + var endPos = emitToken(70, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.variableDeclaration); - emitToken(17, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73, node.pos); + emitToken(74, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -25919,7 +26314,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215); + } while (node && node.kind !== 216); return node; } function emitContainingModuleName(node) { @@ -25938,16 +26333,33 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7); + var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(174); + var result = ts.createSynthesizedNode(175); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); + if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1) { writeLine(); @@ -25958,7 +26370,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25966,6 +26378,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25984,44 +26397,48 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - 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); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 208) { + if (root.kind === 209) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135) { + else if (root.kind === 136) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178) { + if (root.kind === 179) { emitAssignmentExpression(root); } else { @@ -26032,11 +26449,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -26052,7 +26469,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66) { + if (expr.kind !== 67) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -26064,37 +26481,37 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(178); + var equals = ts.createSynthesizedNode(179); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31); + equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179); + var cond = ts.createSynthesizedNode(180); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51); + cond.questionToken = ts.createSynthesizedNode(52); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52); + cond.colonToken = ts.createSynthesizedNode(53); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7); + var node = ts.createSynthesizedNode(8); node.text = "" + value; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66) { + if (syntheticName.kind !== 67) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165); - var sliceIdentifier = ts.createSynthesizedNode(66); + var call = ts.createSynthesizedNode(166); + var sliceIdentifier = ts.createSynthesizedNode(67); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -26108,7 +26525,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -26121,8 +26538,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -26132,14 +26549,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161) { + else if (target.kind === 162) { emitArrayLiteralAssignment(target, value); } else { @@ -26149,18 +26566,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write(")"); } } @@ -26180,11 +26600,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184) { + else if (element.kind !== 185) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -26215,15 +26635,15 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 197 && - node.parent.parent.kind !== 198) { + node.parent.parent.kind !== 198 && + node.parent.parent.kind !== 199) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -26234,11 +26654,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184) { + if (node.kind === 185) { return; } var name = node.name; - if (name.kind === 66) { + if (name.kind === 67) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -26246,7 +26666,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { + if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -26254,7 +26674,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 245; + node.parent.kind === 246; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -26352,9 +26772,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -26373,7 +26793,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -26394,7 +26814,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -26403,26 +26823,26 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 ? "get " : "set "); + write(node.kind === 143 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 && languageVersion >= 2; + return node.kind === 172 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170) { + if (node.kind === 171) { return !!node.name; } - if (node.kind === 210) { + if (node.kind === 211) { return !!node.name || languageVersion < 2; } } @@ -26430,9 +26850,12 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 && node.kind !== 139) { + if (node.kind !== 141 && node.kind !== 140 && + node.parent && node.parent.kind !== 243 && + node.parent.kind !== 166) { emitLeadingComments(node); } + emitStart(node); if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); @@ -26450,10 +26873,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 && node.kind !== 139) { + emitEnd(node); + if (node.kind !== 141 && node.kind !== 140) { emitTrailingComments(node); } } @@ -26485,7 +26909,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171; + var isArrowFunction = node.kind === 172; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26528,7 +26952,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26576,10 +27000,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 168) { + while (current.kind === 169) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162); + emitParenthesizedIf(body, current.kind === 163); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26645,17 +27069,17 @@ var ts; emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15, body.statements.end); + emitToken(16, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192) { + if (statement && statement.kind === 193) { var expr = statement.expression; - if (expr && expr.kind === 165) { + if (expr && expr.kind === 166) { var func = expr.expression; - if (func && func.kind === 92) { + if (func && func.kind === 93) { return statement; } } @@ -26679,24 +27103,24 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 8 || memberName.kind === 7) { + if (memberName.kind === 9 || memberName.kind === 8) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133) { + else if (memberName.kind === 134) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -26736,11 +27160,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188) { + if (member.kind === 189) { writeLine(); write(";"); } - else if (member.kind === 140 || node.kind === 139) { + else if (member.kind === 141 || node.kind === 140) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -26752,14 +27176,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 || member.kind === 143) { + else if (member.kind === 143 || member.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26809,22 +27231,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 || node.kind === 139) && !member.body) { + if ((member.kind === 141 || node.kind === 140) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 || - member.kind === 142 || - member.kind === 143) { + else if (member.kind === 141 || + member.kind === 143 || + member.kind === 144) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 142) { + if (member.kind === 143) { write("get "); } - else if (member.kind === 143) { + else if (member.kind === 144) { write("set "); } if (member.asteriskToken) { @@ -26835,7 +27257,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26856,10 +27278,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 141 && !member.body) { + if (member.kind === 142 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -26890,18 +27312,21 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -26928,7 +27353,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26936,7 +27361,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -26959,7 +27384,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211) { + if (node.kind === 212) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -26976,7 +27401,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -27003,7 +27428,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -27043,7 +27468,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -27081,7 +27506,7 @@ var ts; writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15, node.members.end, function () { + emitToken(16, node.members.end, function () { write("return "); emitDeclarationName(node); }); @@ -27093,7 +27518,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -27101,11 +27526,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211) { + if (node.kind === 212) { write(";"); } emitEnd(node); - if (node.kind === 211) { + if (node.kind === 212) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -27179,13 +27604,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 140) { + if (member.kind === 141) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 138) { + if (member.kind !== 139) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27215,7 +27640,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138) { + if (member.kind !== 139) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27254,45 +27679,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 140: - case 142: + case 141: case 143: - case 138: + case 144: + case 139: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 140: + case 141: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 211: - case 140: - case 143: + case 212: + case 141: + case 144: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 211: + case 212: write("Function"); return; - case 138: + case 139: emitSerializedTypeNode(node.type); return; - case 135: - emitSerializedTypeNode(node.type); - return; - case 142: + case 136: emitSerializedTypeNode(node.type); return; case 143: + emitSerializedTypeNode(node.type); + return; + case 144: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -27303,43 +27728,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100: + case 101: write("void 0"); return; - case 157: + case 158: emitSerializedTypeNode(node.type); return; - case 149: case 150: + case 151: write("Function"); return; - case 153: case 154: + case 155: write("Array"); return; - case 147: - case 117: + case 148: + case 118: write("Boolean"); return; - case 127: - case 8: + case 128: + case 9: write("String"); return; - case 125: + case 126: write("Number"); return; - case 128: + case 129: write("Symbol"); return; - case 148: + case 149: emitSerializedTypeReferenceNode(node); return; - case 151: case 152: - case 155: + case 153: case 156: - case 114: + case 157: + case 115: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -27348,8 +27776,13 @@ var ts; write("Object"); } function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0); @@ -27398,7 +27831,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 211) { + if (node.kind === 212) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -27414,10 +27847,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153) { + if (parameterType.kind === 154) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27434,7 +27867,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27511,7 +27944,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27570,7 +28003,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215) { + if (moduleDeclaration.body.kind === 216) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27605,7 +28038,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216) { + if (node.body.kind === 217) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27624,7 +28057,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27637,7 +28070,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -27649,29 +28082,41 @@ var ts; emitExportMemberAssignments(node.name); } } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8) { + if (moduleName.kind === 9) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 && node.importClause && !!node.importClause.name; + return node.kind === 220 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27698,7 +28143,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27724,7 +28169,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -27736,7 +28181,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27782,16 +28227,29 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } } - else if (!(node.flags & 1)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -27819,11 +28277,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -27845,7 +28303,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27857,10 +28314,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27873,13 +28329,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -27892,8 +28346,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 && - expression.kind !== 211) { + if (expression.kind !== 211 && + expression.kind !== 212) { write(";"); } emitEnd(node); @@ -27907,6 +28361,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27929,18 +28384,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219: + case 220: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 218: - if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { + case 219: + if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 225: + case 226: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -27958,7 +28413,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27983,17 +28438,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 && node.importClause) { + if (node.kind === 220 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 && node.moduleSpecifier) { + if (node.kind === 226 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - return getLiteralText(moduleName); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -28005,8 +28460,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 225 || - (importNode.kind === 219 && !importNode.importClause); + var skipNode = importNode.kind === 226 || + (importNode.kind === 220 && !importNode.importClause); if (skipNode) { continue; } @@ -28031,7 +28486,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 && externalImport.exportClause) { + if (externalImport.kind === 226 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -28060,7 +28515,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225) { + if (externalImport.kind !== 226) { continue; } var exportDecl = externalImport; @@ -28082,6 +28537,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -28089,17 +28546,19 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 66 && node.flags & 1024) { + if (node.kind !== 67 && node.flags & 1024) { return; } if (started) { @@ -28110,8 +28569,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -28130,7 +28589,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_26 = local.kind === 66 + var name_26 = local.kind === 67 ? local : local.name; if (name_26) { @@ -28145,13 +28604,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 || local.kind === 215 || local.kind === 214) { + if (local.kind === 212 || local.kind === 216 || local.kind === 215) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -28179,21 +28638,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 210) { + if (node.kind === 211) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211) { + if (node.kind === 212) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214) { + if (node.kind === 215) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28202,7 +28661,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28211,10 +28670,10 @@ var ts; } return; } - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { if (shouldHoistVariable(node, false)) { var name_27 = node.name; - if (name_27.kind === 66) { + if (name_27.kind === 67) { if (!hoistedVars) { hoistedVars = []; } @@ -28226,6 +28685,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -28240,12 +28706,12 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245; + ts.getEnclosingBlockScopeContainer(node).kind === 246; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); writeLine(); var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); @@ -28254,7 +28720,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -28262,75 +28728,64 @@ var ts; write("}"); emitTempDeclarations(true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219: - if (!importNode.importClause) { - break; - } - case 218: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220: + if (!entry.importClause) { + break; + } + case 219: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221) { - emitExportMemberAssignments(namedBindings.name); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } 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 225: - 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("\"]);"); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -28343,14 +28798,25 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 225: - case 219: - case 218: - case 210: + case 211: + case 220: continue; + case 226: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -28366,8 +28832,19 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -28376,8 +28853,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -28435,6 +28913,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28454,6 +28933,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28462,6 +28942,7 @@ var ts; emitExportEquals(false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); emitAMDDependencies(node, false); @@ -28481,6 +28962,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28506,7 +28988,7 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; var text = ts.getTextOfNode(node); var firstNonWhitespace = 0; @@ -28516,7 +28998,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -28529,15 +29011,25 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -28551,13 +29043,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -28566,9 +29058,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28600,10 +29092,7 @@ var ts; } } } - function emitSourceFileNode(node) { - writeLine(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLines(extendsHelper); @@ -28625,6 +29114,12 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); @@ -28647,47 +29142,63 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 213: + case 211: + case 220: + case 219: + case 214: + case 225: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 212: - case 210: - case 219: - case 218: - case 213: - case 224: - return false; - case 190: + case 191: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215: + case 216: return shouldEmitModuleDeclaration(node); - case 214: + case 215: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 189 && + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 190 && node.parent && - node.parent.kind === 171 && + node.parent.kind === 172 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -28696,170 +29207,170 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 66: + case 67: return emitIdentifier(node); - case 135: + case 136: return emitParameter(node); + case 141: case 140: - case 139: return emitMethod(node); - case 142: case 143: + case 144: return emitAccessor(node); - case 94: + case 95: return emitThis(node); - case 92: + case 93: return emitSuper(node); - case 90: + case 91: return write("null"); - case 96: + case 97: return write("true"); - case 81: + case 82: return write("false"); - case 7: case 8: case 9: case 10: case 11: case 12: case 13: + case 14: return emitLiteral(node); - case 180: - return emitTemplateExpression(node); - case 187: - return emitTemplateSpan(node); - case 230: - case 231: - return emitJsxElement(node); - case 233: - return emitJsxText(node); - case 237: - return emitJsxExpression(node); - case 132: - return emitQualifiedName(node); - case 158: - return emitObjectBindingPattern(node); - case 159: - return emitArrayBindingPattern(node); - case 160: - return emitBindingElement(node); - case 161: - return emitArrayLiteral(node); - case 162: - return emitObjectLiteral(node); - case 242: - return emitPropertyAssignment(node); - case 243: - return emitShorthandPropertyAssignment(node); - case 133: - return emitComputedPropertyName(node); - case 163: - return emitPropertyAccess(node); - case 164: - return emitIndexedAccess(node); - case 165: - return emitCallExpression(node); - case 166: - return emitNewExpression(node); - case 167: - return emitTaggedTemplateExpression(node); - case 168: - return emit(node.expression); - case 186: - return emit(node.expression); - case 169: - return emitParenExpression(node); - case 210: - case 170: - case 171: - return emitFunctionDeclaration(node); - case 172: - return emitDeleteExpression(node); - case 173: - return emitTypeOfExpression(node); - case 174: - return emitVoidExpression(node); - case 175: - return emitAwaitExpression(node); - case 176: - return emitPrefixUnaryExpression(node); - case 177: - return emitPostfixUnaryExpression(node); - case 178: - return emitBinaryExpression(node); - case 179: - return emitConditionalExpression(node); - case 182: - return emitSpreadElementExpression(node); case 181: - return emitYieldExpression(node); - case 184: - return; - case 189: - case 216: - return emitBlock(node); - case 190: - return emitVariableStatement(node); - case 191: - return write(";"); - case 192: - return emitExpressionStatement(node); - case 193: - return emitIfStatement(node); - case 194: - return emitDoStatement(node); - case 195: - return emitWhileStatement(node); - case 196: - return emitForStatement(node); - case 198: - case 197: - return emitForInOrForOfStatement(node); - case 199: - case 200: - return emitBreakOrContinueStatement(node); - case 201: - return emitReturnStatement(node); - case 202: - return emitWithStatement(node); - case 203: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 188: + return emitTemplateSpan(node); + case 231: + case 232: + return emitJsxElement(node); + case 234: + return emitJsxText(node); case 238: - case 239: - return emitCaseOrDefaultClause(node); - case 204: - return emitLabelledStatement(node); - case 205: - return emitThrowStatement(node); - case 206: - return emitTryStatement(node); - case 241: - return emitCatchClause(node); - case 207: - return emitDebuggerStatement(node); - case 208: - return emitVariableDeclaration(node); - case 183: - return emitClassExpression(node); - case 211: - return emitClassDeclaration(node); - case 212: - return emitInterfaceDeclaration(node); - case 214: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 133: + return emitQualifiedName(node); + case 159: + return emitObjectBindingPattern(node); + case 160: + return emitArrayBindingPattern(node); + case 161: + return emitBindingElement(node); + case 162: + return emitArrayLiteral(node); + case 163: + return emitObjectLiteral(node); + case 243: + return emitPropertyAssignment(node); case 244: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 134: + return emitComputedPropertyName(node); + case 164: + return emitPropertyAccess(node); + case 165: + return emitIndexedAccess(node); + case 166: + return emitCallExpression(node); + case 167: + return emitNewExpression(node); + case 168: + return emitTaggedTemplateExpression(node); + case 169: + return emit(node.expression); + case 187: + return emit(node.expression); + case 170: + return emitParenExpression(node); + case 211: + case 171: + case 172: + return emitFunctionDeclaration(node); + case 173: + return emitDeleteExpression(node); + case 174: + return emitTypeOfExpression(node); + case 175: + return emitVoidExpression(node); + case 176: + return emitAwaitExpression(node); + case 177: + return emitPrefixUnaryExpression(node); + case 178: + return emitPostfixUnaryExpression(node); + case 179: + return emitBinaryExpression(node); + case 180: + return emitConditionalExpression(node); + case 183: + return emitSpreadElementExpression(node); + case 182: + return emitYieldExpression(node); + case 185: + return; + case 190: + case 217: + return emitBlock(node); + case 191: + return emitVariableStatement(node); + case 192: + return write(";"); + case 193: + return emitExpressionStatement(node); + case 194: + return emitIfStatement(node); + case 195: + return emitDoStatement(node); + case 196: + return emitWhileStatement(node); + case 197: + return emitForStatement(node); + case 199: + case 198: + return emitForInOrForOfStatement(node); + case 200: + case 201: + return emitBreakOrContinueStatement(node); + case 202: + return emitReturnStatement(node); + case 203: + return emitWithStatement(node); + case 204: + return emitSwitchStatement(node); + case 239: + case 240: + return emitCaseOrDefaultClause(node); + case 205: + return emitLabelledStatement(node); + case 206: + return emitThrowStatement(node); + case 207: + return emitTryStatement(node); + case 242: + return emitCatchClause(node); + case 208: + return emitDebuggerStatement(node); + case 209: + return emitVariableDeclaration(node); + case 184: + return emitClassExpression(node); + case 212: + return emitClassDeclaration(node); + case 213: + return emitInterfaceDeclaration(node); case 215: - return emitModuleDeclaration(node); - case 219: - return emitImportDeclaration(node); - case 218: - return emitImportEqualsDeclaration(node); - case 225: - return emitExportDeclaration(node); - case 224: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 245: + return emitEnumMember(node); + case 216: + return emitModuleDeclaration(node); + case 220: + return emitImportDeclaration(node); + case 219: + return emitImportEqualsDeclaration(node); + case 226: + return emitExportDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFileNode(node); } } @@ -28887,7 +29398,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -28899,7 +29410,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.end !== node.parent.end) { + if (node.parent.kind === 246 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -28919,6 +29430,10 @@ var ts; var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { @@ -28964,6 +29479,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; @@ -28984,6 +29505,261 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// @@ -28993,7 +29769,8 @@ var ts; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -29010,6 +29787,49 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + return legacyNameResolver(moduleName, containingFile, compilerOptions, host); + } + ts.resolveModuleName = resolveModuleName; + function legacyNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -29072,7 +29892,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -29107,7 +29929,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -29118,14 +29940,30 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -29157,6 +29995,58 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -29183,7 +30073,7 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -29264,14 +30154,51 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220: + case 219: + case 226: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -29302,15 +30229,15 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); @@ -29322,8 +30249,8 @@ var ts; return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -29333,11 +30260,11 @@ var ts; if (file) { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -29353,7 +30280,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -29361,49 +30293,30 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 || node.kind === 218 || node.kind === 225) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 && 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) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -29455,28 +30368,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -29484,16 +30397,20 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } 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)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2) { @@ -29515,7 +30432,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); } @@ -29527,16 +30444,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2) { @@ -29587,128 +30510,128 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return spanInPreviousNode(node); } - if (node.parent.kind === 196) { + if (node.parent.kind === 197) { return textSpan(node); } - if (node.parent.kind === 178 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 179 && node.parent.operatorToken.kind === 24) { return textSpan(node); } - if (node.parent.kind === 171 && node.parent.body === node) { + if (node.parent.kind === 172 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 190: + case 191: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208: - case 138: - case 137: - return spanInVariableDeclaration(node); - case 135: - return spanInParameterDeclaration(node); - case 210: - case 140: + case 209: case 139: - case 142: - case 143: + case 138: + return spanInVariableDeclaration(node); + case 136: + return spanInParameterDeclaration(node); + case 211: case 141: - case 170: + case 140: + case 143: + case 144: + case 142: case 171: + case 172: return spanInFunctionDeclaration(node); - case 189: + case 190: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 216: + case 217: return spanInBlock(node); - case 241: + case 242: return spanInBlock(node.block); - case 192: - return textSpan(node.expression); - case 201: - return textSpan(node.getChildAt(0), node.expression); - case 195: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 194: - return spanInNode(node.statement); - case 207: - return textSpan(node.getChildAt(0)); case 193: + return textSpan(node.expression); + case 202: + return textSpan(node.getChildAt(0), node.expression); + case 196: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 195: + return spanInNode(node.statement); + case 208: + return textSpan(node.getChildAt(0)); + case 194: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 205: + return spanInNode(node.statement); + case 201: + case 200: + return textSpan(node.getChildAt(0), node.label); + case 197: + return spanInForStatement(node); + case 198: + case 199: return textSpan(node, ts.findNextToken(node.expression, node)); case 204: - return spanInNode(node.statement); - case 200: - case 199: - return textSpan(node.getChildAt(0), node.label); - case 196: - return spanInForStatement(node); - case 197: - case 198: return textSpan(node, ts.findNextToken(node.expression, node)); - case 203: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 238: case 239: + case 240: return spanInNode(node.statements[0]); - case 206: + case 207: return spanInBlock(node.tryBlock); - case 205: + case 206: return textSpan(node, node.expression); - case 224: - return textSpan(node, node.expression); - case 218: - return textSpan(node, node.moduleReference); - case 219: - return textSpan(node, node.moduleSpecifier); case 225: + return textSpan(node, node.expression); + case 219: + return textSpan(node, node.moduleReference); + case 220: return textSpan(node, node.moduleSpecifier); - case 215: + case 226: + return textSpan(node, node.moduleSpecifier); + case 216: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 211: - case 214: - case 244: - case 165: - case 166: - return textSpan(node); - case 202: - return spanInNode(node.statement); case 212: + case 215: + case 245: + case 166: + case 167: + return textSpan(node); + case 203: + return spanInNode(node.statement); case 213: + case 214: return undefined; - case 22: + case 23: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23: - return spanInPreviousNode(node); - case 14: - return spanInOpenBraceToken(node); - case 15: - return spanInCloseBraceToken(node); - case 16: - return spanInOpenParenToken(node); - case 17: - return spanInCloseParenToken(node); - case 52: - return spanInColonToken(node); - case 26: case 24: + return spanInPreviousNode(node); + case 15: + return spanInOpenBraceToken(node); + case 16: + return spanInCloseBraceToken(node); + case 17: + return spanInOpenParenToken(node); + case 18: + return spanInCloseParenToken(node); + case 53: + return spanInColonToken(node); + case 27: + case 25: return spanInGreaterThanOrLessThanToken(node); - case 101: + case 102: return spanInWhileKeyword(node); - case 77: - case 69: - case 82: + case 78: + case 70: + case 83: return spanInNextNode(node); default: - if (node.parent.kind === 242 && node.parent.name === node) { + if (node.parent.kind === 243 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 168 && node.parent.type === node) { + if (node.parent.kind === 169 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -29718,12 +30641,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 197 || - variableDeclaration.parent.parent.kind === 198) { + if (variableDeclaration.parent.parent.kind === 198 || + variableDeclaration.parent.parent.kind === 199) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -29769,7 +30692,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 211 && functionDeclaration.kind !== 141); + (functionDeclaration.parent.kind === 212 && functionDeclaration.kind !== 142); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -29789,23 +30712,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215: + case 216: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 195: - case 193: - case 197: - case 198: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 196: + case 194: + case 198: + case 199: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 197: 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 === 209) { + if (forStatement.initializer.kind === 210) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -29824,34 +30747,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214: + case 215: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211: + case 212: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217: + case 218: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216: + case 217: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 214: - case 211: + case 215: + case 212: return textSpan(node); - case 189: + case 190: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 241: + case 242: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217: + case 218: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -29863,24 +30786,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 170: - case 210: case 171: - case 140: - case 139: - case 142: - case 143: + case 211: + case 172: case 141: - case 195: - case 194: + case 140: + case 143: + case 144: + case 142: case 196: + case 195: + case 197: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -29888,19 +30811,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168) { + if (node.parent.kind === 169) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -29978,7 +30901,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171; + return ts.isFunctionBlock(node) && node.parent.kind !== 172; } var depth = 0; var maxDepth = 20; @@ -29990,30 +30913,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189: + case 190: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (parent_8.kind === 194 || - parent_8.kind === 197 || - parent_8.kind === 198 || - parent_8.kind === 196 || - parent_8.kind === 193 || - parent_8.kind === 195 || - parent_8.kind === 202 || - parent_8.kind === 241) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + if (parent_7.kind === 195 || + parent_7.kind === 198 || + parent_7.kind === 199 || + parent_7.kind === 197 || + parent_7.kind === 194 || + parent_7.kind === 196 || + parent_7.kind === 203 || + parent_7.kind === 242) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206) { - var tryStatement = parent_8; + if (parent_7.kind === 207) { + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -30029,25 +30952,25 @@ var ts; }); break; } - case 216: { - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + case 217: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211: case 212: - case 214: - case 162: - case 217: { - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + case 213: + case 215: + case 163: + case 218: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161: - var openBracket = ts.findChildOfKind(n, 18, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19, sourceFile); + case 162: + var openBracket = ts.findChildOfKind(n, 19, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -30115,9 +31038,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 || - node.kind === 8 || - node.kind === 7) { + if (node.kind === 67 || + node.kind === 9 || + node.kind === 8) { return node.text; } } @@ -30129,7 +31052,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133) { + else if (declaration.name.kind === 134) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -30146,7 +31069,7 @@ var ts; } return true; } - if (expression.kind === 163) { + if (expression.kind === 164) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -30157,7 +31080,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 133) { + if (declaration.name.kind === 134) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -30221,14 +31144,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215: + case 216: do { current = current.parent; - } while (current.kind === 215); - case 211: - case 214: + } while (current.kind === 216); case 212: - case 210: + case 215: + case 213: + case 211: indent++; } current = current.parent; @@ -30239,26 +31162,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190: + case 191: ts.forEach(node.declarationList.declarations, visit); break; - case 158: case 159: + case 160: ts.forEach(node.elements, visit); break; - case 225: + case 226: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219: + case 220: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { childNodes.push(importClause.namedBindings); } else { @@ -30267,20 +31190,20 @@ var ts; } } break; - case 160: - case 208: + case 161: + case 209: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 211: - case 214: case 212: case 215: - case 210: - case 218: - case 223: - case 227: + case 213: + case 216: + case 211: + case 219: + case 224: + case 228: childNodes.push(node); break; } @@ -30315,17 +31238,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211: - case 214: case 212: + case 215: + case 213: topLevelNodes.push(node); break; - case 215: + case 216: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210: + case 211: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -30336,9 +31259,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210) { - if (functionDeclaration.body && functionDeclaration.body.kind === 189) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 211) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -30391,7 +31314,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135: + case 136: if (ts.isBindingPattern(node.name)) { break; } @@ -30399,34 +31322,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 141: case 140: - case 139: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 143: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 144: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138: - case 137: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 147: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 245: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210: + case 145: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 146: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 139: + case 138: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 211: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208: - case 160: + case 209: + case 161: var variableDeclarationNode; var name_29; - if (node.kind === 160) { + if (node.kind === 161) { name_29 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 208) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -30445,13 +31368,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141: + case 142: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227: - case 223: - case 218: - case 220: + case 228: + case 224: + case 219: case 221: + case 222: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -30481,27 +31404,27 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245: + case 246: return createSourceFileItem(node); - case 211: - return createClassItem(node); - case 214: - return createEnumItem(node); case 212: - return createIterfaceItem(node); + return createClassItem(node); case 215: + return createEnumItem(node); + case 213: + return createIterfaceItem(node); + case 216: return createModuleItem(node); - case 210: + case 211: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { - if (moduleDeclaration.name.kind === 8) { + if (moduleDeclaration.name.kind === 9) { return getTextOfNode(moduleDeclaration.name); } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -30513,7 +31436,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 === 189) { + if (node.body && node.body.kind === 190) { 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)); } @@ -30534,7 +31457,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 && member; + return member.kind === 142 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -30555,19 +31478,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215) { + while (node.body.kind === 216) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 + return node.kind === 246 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -31058,14 +31981,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165) { + if (argumentInfo.invocation.kind !== 166) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 + var name = expression.kind === 67 ? expression - : expression.kind === 163 + : expression.kind === 164 ? expression.name : undefined; if (!name || !name.text) { @@ -31094,10 +32017,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 || node.parent.kind === 166) { + if (node.parent.kind === 166 || node.parent.kind === 167) { var callExpression = node.parent; - if (node.kind === 24 || - node.kind === 16) { + if (node.kind === 25 || + node.kind === 17) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -31125,24 +32048,24 @@ var ts; }; } } - else if (node.kind === 10 && node.parent.kind === 167) { + else if (node.kind === 11 && node.parent.kind === 168) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 167) { + else if (node.kind === 12 && node.parent.parent.kind === 168) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180); + ts.Debug.assert(templateExpression.kind === 181); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 && node.parent.parent.parent.kind === 167) { + else if (node.parent.kind === 188 && node.parent.parent.parent.kind === 168) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180); - if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 181); + if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -31159,7 +32082,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23) { + if (child.kind !== 24) { argumentIndex++; } } @@ -31167,8 +32090,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24) { argumentCount++; } return argumentCount; @@ -31184,7 +32107,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { - var argumentCount = tagExpression.template.kind === 10 + var argumentCount = tagExpression.template.kind === 11 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -31205,7 +32128,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 180) { + if (template.kind === 181) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -31214,7 +32137,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245; n = n.parent) { + for (var n = node; n.kind !== 246; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -31264,10 +32187,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24)); + prefixDisplayParts.push(ts.punctuationPart(25)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26)); + suffixDisplayParts.push(ts.punctuationPart(27)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -31278,10 +32201,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16)); + prefixDisplayParts.push(ts.punctuationPart(17)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17)); + suffixDisplayParts.push(ts.punctuationPart(18)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -31291,7 +32214,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -31314,12 +32237,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -31395,101 +32317,101 @@ var ts; return false; } switch (n.kind) { - case 211: case 212: - case 214: - case 162: - case 158: - case 152: - case 189: - case 216: + case 213: + case 215: + case 163: + case 159: + case 153: + case 190: case 217: - return nodeEndsWith(n, 15, sourceFile); - case 241: + case 218: + return nodeEndsWith(n, 16, sourceFile); + case 242: return isCompletedNode(n.block, sourceFile); - case 166: + case 167: if (!n.arguments) { return true; } - case 165: - case 169: - case 157: - return nodeEndsWith(n, 17, sourceFile); - case 149: + case 166: + case 170: + case 158: + return nodeEndsWith(n, 18, sourceFile); case 150: + case 151: return isCompletedNode(n.type, sourceFile); - case 141: case 142: case 143: - case 210: - case 170: - case 140: - case 139: - case 145: case 144: + case 211: case 171: + case 141: + case 140: + case 146: + case 145: + case 172: if (n.body) { return isCompletedNode(n.body, sourceFile); } if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 17, sourceFile); - case 215: + return hasChildOfKind(n, 18, sourceFile); + case 216: return n.body && isCompletedNode(n.body, sourceFile); - case 193: + case 194: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192: + case 193: return isCompletedNode(n.expression, sourceFile); - case 161: - case 159: - case 164: - case 133: - case 154: - return nodeEndsWith(n, 19, sourceFile); - case 146: + case 162: + case 160: + case 165: + case 134: + case 155: + return nodeEndsWith(n, 20, sourceFile); + case 147: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19, sourceFile); - case 238: + return hasChildOfKind(n, 20, sourceFile); case 239: + case 240: return false; - case 196: case 197: case 198: - case 195: + case 199: + case 196: return isCompletedNode(n.statement, sourceFile); - case 194: - var hasWhileKeyword = findChildOfKind(n, 101, sourceFile); + case 195: + var hasWhileKeyword = findChildOfKind(n, 102, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17, sourceFile); + return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151: + case 152: return isCompletedNode(n.exprName, sourceFile); - case 173: - case 172: case 174: - case 181: + case 173: + case 175: case 182: + case 183: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167: + case 168: return isCompletedNode(n.template, sourceFile); - case 180: + case 181: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187: + case 188: return ts.nodeIsPresent(n.literal); - case 176: + case 177: return isCompletedNode(n.operand, sourceFile); - case 178: - return isCompletedNode(n.right, sourceFile); case 179: + return isCompletedNode(n.right, sourceFile); + case 180: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -31503,7 +32425,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 && children.length !== 1) { + else if (last.kind === 23 && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -31532,7 +32454,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 268 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -31638,7 +32560,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245); + ts.Debug.assert(startNode !== undefined || n.kind === 246); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -31653,6 +32575,39 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, undefined); + } + ts.isInComment = isInComment; + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; function nodeHasTokens(n) { return n.getWidth() !== 0; } @@ -31677,32 +32632,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 || node.kind === 165) { + if (node.kind === 149 || node.kind === 166) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 || node.kind === 212) { + if (ts.isFunctionLike(node) || node.kind === 212 || node.kind === 213) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 131; + return n.kind >= 0 && n.kind <= 132; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 || ts.isKeyword(kind); + return kind === 67 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 || kind === 7 || isWord(kind); + return kind === 9 || kind === 8 || isWord(kind); } function isComment(kind) { return kind === 2 || kind === 3; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 <= kind && kind <= 65; + return 15 <= kind && kind <= 66; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -31712,9 +32667,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109: - case 107: + case 110: case 108: + case 109: return true; } return false; @@ -31740,7 +32695,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -31875,6 +32830,11 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -31915,7 +32875,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 || location.parent.kind === 227) && + (location.parent.kind === 224 || location.parent.kind === 228) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -31998,25 +32958,25 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28: - case 61: + case 29: case 62: + case 63: + case 44: case 43: - case 42: return true; } } return false; } function shouldRescanSlashToken(container) { - return container.kind === 9; + return container.kind === 10; } function shouldRescanTemplateToken(container) { - return container.kind === 12 || - container.kind === 13; + return container.kind === 13 || + container.kind === 14; } function startsWithSlashToken(t) { - return t === 37 || t === 58; + return t === 38 || t === 59; } function readTokenInfo(n) { if (!isOnToken()) { @@ -32042,7 +33002,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 26) { + if (expectedScanAction === 1 && currentToken === 27) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -32052,7 +33012,7 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 15) { + else if (expectedScanAction === 3 && currentToken === 16) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } @@ -32173,8 +33133,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -32317,79 +33277,78 @@ var ts; /// this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 77), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 101), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.FromTokens([17, 19, 23, 22])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 78), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 102), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66, 3]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 76, 97, 82, 77]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 77, 98, 83, 78]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99, 95, 89, 75, 91, 98]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 76, 77, 68]), 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([97, 82]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120, 126]), 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 77, 78, 69]), 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([98, 83]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121, 127]), 67), 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(118, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122, 124]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 70, 119, 74, 78, 79, 80, 120, 103, 86, 104, 122, 123, 107, 109, 108, 126, 110]), 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([80, 103])), 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(33, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.FromTokens([16, 18, 26, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - 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, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53, 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([112, 66, 79, 74, 70, 110, 109, 107, 108, 120, 126, 18, 36])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36, formatting.Shared.TokenRange.FromTokens([66, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111, 36]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111]), 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([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54, 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([113, 67, 80, 75, 71, 111, 110, 108, 109, 121, 127, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -32427,6 +33386,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -32436,32 +33396,37 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -32473,31 +33438,31 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 196; + return context.contextNode.kind === 197; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178: case 179: - case 186: - case 147: + case 180: + case 187: + case 148: return true; - case 160: - case 213: - case 218: - case 208: - case 135: - case 244: + case 161: + case 214: + case 219: + case 209: + case 136: + case 245: + case 139: case 138: - case 137: - return context.currentTokenSpan.kind === 54 || context.nextTokenSpan.kind === 54; - case 197: - return context.currentTokenSpan.kind === 87 || context.nextTokenSpan.kind === 87; + return context.currentTokenSpan.kind === 55 || context.nextTokenSpan.kind === 55; case 198: - return context.currentTokenSpan.kind === 131 || context.nextTokenSpan.kind === 131; + return context.currentTokenSpan.kind === 88 || context.nextTokenSpan.kind === 88; + case 199: + return context.currentTokenSpan.kind === 132 || context.nextTokenSpan.kind === 132; } return false; }; @@ -32505,7 +33470,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179; + return context.contextNode.kind === 180; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -32546,91 +33511,91 @@ var ts; return true; } switch (node.kind) { - case 189: + case 190: + case 218: + case 163: case 217: - case 162: - case 216: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: case 144: - case 170: - case 141: + case 145: case 171: - case 212: + case 142: + case 172: + case 213: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 || context.contextNode.kind === 170; + return context.contextNode.kind === 211 || context.contextNode.kind === 171; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211: case 212: - case 214: - case 152: + case 213: case 215: + case 153: + case 216: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211: - case 215: - case 214: - case 189: - case 241: + case 212: case 216: - case 203: + case 215: + case 190: + case 242: + case 217: + case 204: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193: - case 203: - case 196: + case 194: + case 204: case 197: case 198: + case 199: + case 196: + case 207: case 195: - case 206: - case 194: - case 202: - case 241: + case 203: + case 242: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162; + return context.contextNode.kind === 163; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165; + return context.contextNode.kind === 166; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166; + return context.contextNode.kind === 167; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23; + return context.currentTokenSpan.kind !== 24; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -32648,52 +33613,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136; + return node.kind === 137; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 && + return context.currentTokenParent.kind === 210 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 215; + return context.contextNode.kind === 216; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152; + return context.contextNode.kind === 153; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 && token.kind !== 26) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 148: - case 211: + case 149: + case 169: case 212: - case 210: - case 170: + case 184: + case 213: + case 211: case 171: + case 172: + case 141: case 140: - case 139: - case 144: case 145: - case 165: + case 146: case 166: + case 167: + case 186: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 && context.currentTokenParent.kind === 174; + return context.currentTokenSpan.kind === 101 && context.currentTokenParent.kind === 175; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -32716,7 +33687,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 + 1; + this.mapRowLength = 132 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -32893,7 +33864,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 131; token++) { + for (var token = 0; token <= 132; token++) { result.push(token); } return result; @@ -32935,17 +33906,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(67, 131); - TokenRange.BinaryOperators = TokenRange.FromRange(24, 65); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87, 88, 131, 113, 121]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39, 40, 48, 47]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 66, 16, 18, 14, 94, 89]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); + TokenRange.Keywords = TokenRange.FromRange(68, 132); + TokenRange.BinaryOperators = TokenRange.FromRange(25, 66); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88, 89, 132, 114, 122]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40, 41, 49, 48]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 67, 17, 19, 15, 95, 90]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([66, 125, 127, 117, 128, 100, 114]); + TokenRange.TypeNames = TokenRange.FromTokens([67, 126, 128, 118, 129, 101, 115]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -33021,6 +33992,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -33071,11 +34052,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -33123,17 +34104,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 211: case 212: + case 213: return ts.rangeContainsRange(parent.members, node); - case 215: - var body = parent.body; - return body && body.kind === 189 && ts.rangeContainsRange(body.statements, node); - case 245: - case 189: case 216: + var body = parent.body; + return body && body.kind === 190 && ts.rangeContainsRange(body.statements, node); + case 246: + case 190: + case 217: return ts.rangeContainsRange(parent.statements, node); - case 241: + case 242: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -33258,9 +34239,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 245 || - parent.kind === 238 || - parent.kind === 239) { + parent.kind === 246 || + parent.kind === 239 || + parent.kind === 240) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -33293,18 +34274,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211: return 70; - case 212: return 104; - case 210: return 84; - case 214: return 214; - case 142: return 120; - case 143: return 126; - case 140: + case 212: return 71; + case 213: return 105; + case 211: return 85; + case 215: return 215; + case 143: return 121; + case 144: return 127; + case 141: if (node.asteriskToken) { - return 36; + return 37; } - case 138: - case 135: + case 139: + case 136: return node.name.kind; } } @@ -33312,8 +34293,8 @@ var ts; return { getIndentationForComment: function (kind) { switch (kind) { - case 15: - case 19: + case 16: + case 20: return indentation + delta; } return indentation; @@ -33325,15 +34306,15 @@ var ts; } } switch (kind) { - case 14: case 15: - case 18: - case 19: case 16: + case 19: + case 20: case 17: - case 77: - case 101: - case 53: + case 18: + case 78: + case 102: + case 54: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -33413,7 +34394,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -33703,49 +34684,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189: - case 216: + case 190: + case 217: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141: - case 210: - case 170: - case 140: - case 139: + case 142: + case 211: case 171: + case 141: + case 140: + case 172: if (node.typeParameters === list) { - return 24; + return 25; } else if (node.parameters === list) { - return 16; + return 17; } break; - case 165: case 166: + case 167: if (node.typeArguments === list) { - return 24; + return 25; } else if (node.arguments === list) { - return 16; + return 17; } break; - case 148: + case 149: if (node.typeArguments === list) { - return 24; + return 25; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16: - return 17; - case 24: - return 26; + case 17: + return 18; + case 25: + return 27; } return 0; } @@ -33815,17 +34796,17 @@ var ts; if (!precedingToken) { return 0; } - var precedingTokenIsLiteral = precedingToken.kind === 8 || - precedingToken.kind === 9 || + var precedingTokenIsLiteral = precedingToken.kind === 9 || precedingToken.kind === 10 || precedingToken.kind === 11 || precedingToken.kind === 12 || - precedingToken.kind === 13; + precedingToken.kind === 13 || + precedingToken.kind === 14; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 178) { + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 179) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -33923,7 +34904,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 245 || !parentAndChildShareLine); + (parent.kind === 246 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -33934,10 +34915,10 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14) { + if (nextToken.kind === 15) { return true; } - else if (nextToken.kind === 15) { + else if (nextToken.kind === 16) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; return lineAtPosition === nextTokenStartLine; } @@ -33947,8 +34928,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77, sourceFile); + if (parent.kind === 194 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -33959,23 +34940,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148: + case 149: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162: + case 163: return node.parent.properties; - case 161: + case 162: return node.parent.elements; - case 210: - case 170: + case 211: case 171: + case 172: + case 141: case 140: - case 139: - case 144: - case 145: { + case 145: + case 146: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -33986,8 +34967,8 @@ var ts; } break; } - case 166: - case 165: { + case 167: + case 166: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -34012,11 +34993,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 17) { + if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 165 || - node.parent.kind === 166) && + if (node.parent && (node.parent.kind === 166 || + node.parent.kind === 167) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -34034,10 +35015,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165: case 166: - case 163: + case 167: case 164: + case 165: node = node.expression; break; default: @@ -34052,7 +35033,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23) { + if (list[i].kind === 24) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -34092,28 +35073,30 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211: case 212: - case 214: - case 161: - case 189: - case 216: + case 213: + case 215: case 162: - case 152: - case 154: - case 217: - case 239: - case 238: - case 169: - case 165: - case 166: case 190: - case 208: - case 224: - case 201: - case 179: + case 217: + case 163: + case 153: + case 155: + case 218: + case 240: + case 239: + case 170: + case 164: + case 166: + case 167: + case 191: + case 209: + case 225: + case 202: + case 180: + case 160: case 159: - case 158: + case 231: return true; } return false; @@ -34123,22 +35106,22 @@ var ts; return true; } switch (parent) { - case 194: case 195: - case 197: - case 198: case 196: - case 193: - case 210: - case 170: - case 140: - case 139: - case 144: + case 198: + case 199: + case 197: + case 194: + case 211: case 171: case 141: + case 140: + case 145: + case 172: case 142: case 143: - return child !== 189; + case 144: + return child !== 190; default: return false; } @@ -34238,7 +35221,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268, nodes.pos, nodes.end, 4096, this); + var list = createNode(269, nodes.pos, nodes.end, 4096, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -34257,7 +35240,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132) { + if (this.kind >= 133) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -34299,24 +35282,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -34358,7 +35337,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 135) { + if (canUseParsedParamTagComments && declaration.kind === 136) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -34366,13 +35345,13 @@ var ts; } }); } - if (declaration.kind === 215 && declaration.body.kind === 215) { + if (declaration.kind === 216 && declaration.body.kind === 216) { return; } - while (declaration.kind === 215 && declaration.parent.kind === 215) { + while (declaration.kind === 216 && declaration.parent.kind === 216) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -34608,6 +35587,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 | 2048) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -34677,9 +35661,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133) { + if (declaration.name.kind === 134) { var expr = declaration.name.expression; - if (expr.kind === 163) { + if (expr.kind === 164) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -34689,9 +35673,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 || - node.kind === 8 || - node.kind === 7) { + if (node.kind === 67 || + node.kind === 9 || + node.kind === 8) { return node.text; } } @@ -34699,9 +35683,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210: + case 211: + case 141: case 140: - case 139: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -34718,62 +35702,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 211: case 212: case 213: case 214: case 215: - case 218: - case 227: - case 223: - case 218: - case 220: - case 221: - case 142: - case 143: - case 152: - addDeclaration(node); - case 141: - case 190: - case 209: - case 158: - case 159: case 216: + case 219: + case 228: + case 224: + case 219: + case 221: + case 222: + case 143: + case 144: + case 153: + addDeclaration(node); + case 142: + case 191: + case 210: + case 159: + case 160: + case 217: ts.forEachChild(node, visit); break; - case 189: + case 190: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135: + case 136: if (!(node.flags & 112)) { break; } - case 208: - case 160: + case 209: + case 161: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244: + case 245: + case 139: case 138: - case 137: addDeclaration(node); break; - case 225: + case 226: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219: + case 220: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { addDeclaration(importClause.namedBindings); } else { @@ -34915,14 +35899,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 170) { + if (declaration.kind === 171) { return true; } - if (declaration.kind !== 208 && declaration.kind !== 210) { + if (declaration.kind !== 209 && declaration.kind !== 211) { return false; } - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { - if (parent_9.kind === 245 || parent_9.kind === 216) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + if (parent_8.kind === 246 || parent_8.kind === 217) { return false; } } @@ -35027,37 +36011,57 @@ var ts; sourceFile.version = version; sourceFile.scriptSnapshot = scriptSnapshot; } - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; options.allowNonTsExtensions = true; options.noLib = true; options.noResolve = true; - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); var outputText; + var sourceMapText; var compilerHost = { getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); + } program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -35112,11 +36116,12 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -35197,6 +36202,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -35212,6 +36218,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -35225,66 +36237,76 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 86) { + if (token === 120) { token = scanner.scan(); - if (token === 8) { + if (token === 123) { + token = scanner.scan(); + if (token === 9) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87) { + token = scanner.scan(); + if (token === 9) { recordModuleName(); continue; } else { - if (token === 66) { + if (token === 67 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); continue; } } - else if (token === 54) { + else if (token === 55) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); - if (token === 16) { + if (token === 17) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); continue; } } } } - else if (token === 23) { + else if (token === 24) { token = scanner.scan(); } else { continue; } } - if (token === 14) { + if (token === 15) { token = scanner.scan(); - while (token !== 15) { + while (token !== 16) { token = scanner.scan(); } - if (token === 15) { + if (token === 16) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } } } - else if (token === 36) { + else if (token === 37) { token = scanner.scan(); - if (token === 113) { + if (token === 114) { token = scanner.scan(); - if (token === 66) { + if (token === 67 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } @@ -35293,28 +36315,28 @@ var ts; } } } - else if (token === 79) { + else if (token === 80) { token = scanner.scan(); - if (token === 14) { + if (token === 15) { token = scanner.scan(); - while (token !== 15) { + while (token !== 16) { token = scanner.scan(); } - if (token === 15) { + if (token === 16) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } } } - else if (token === 36) { + else if (token === 37) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } @@ -35328,12 +36350,12 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -35341,17 +36363,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 && - (node.parent.kind === 200 || node.parent.kind === 199) && + return node.kind === 67 && + (node.parent.kind === 201 || node.parent.kind === 200) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 && - node.parent.kind === 204 && + return node.kind === 67 && + node.parent.kind === 205 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -35362,55 +36384,55 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 && node.parent.right === node; + return node.parent.kind === 133 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 && node.parent.name === node; + return node.parent.kind === 216 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 && + return node.kind === 67 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 66 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 242 || node.parent.kind === 243) && node.parent.name === node; + return (node.kind === 67 || node.kind === 9 || node.kind === 8) && + (node.parent.kind === 243 || node.parent.kind === 244) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 || node.kind === 7) { + if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 138: - case 137: - case 242: - case 244: - case 140: case 139: - case 142: + case 138: + case 243: + case 245: + case 141: + case 140: case 143: - case 215: + case 144: + case 216: return node.parent.name === node; - case 164: + case 165: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8) { + if (node.kind === 9) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -35441,7 +36463,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 67; i <= 131; i++) { + for (var i = 68; i <= 132; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -35456,17 +36478,17 @@ var ts; return undefined; } switch (node.kind) { - case 245: + case 246: + case 141: case 140: - case 139: - case 210: - case 170: - case 142: - case 143: case 211: + case 171: + case 143: + case 144: case 212: - case 214: + case 213: case 215: + case 216: return node; } } @@ -35474,38 +36496,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 215: return ScriptElementKind.moduleElement; - case 211: return ScriptElementKind.classElement; - case 212: return ScriptElementKind.interfaceElement; - case 213: return ScriptElementKind.typeElement; - case 214: return ScriptElementKind.enumElement; - case 208: + case 216: return ScriptElementKind.moduleElement; + case 212: return ScriptElementKind.classElement; + case 213: return ScriptElementKind.interfaceElement; + case 214: return ScriptElementKind.typeElement; + case 215: return ScriptElementKind.enumElement; + case 209: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210: return ScriptElementKind.functionElement; - case 142: return ScriptElementKind.memberGetAccessorElement; - case 143: return ScriptElementKind.memberSetAccessorElement; + case 211: return ScriptElementKind.functionElement; + case 143: return ScriptElementKind.memberGetAccessorElement; + case 144: return ScriptElementKind.memberSetAccessorElement; + case 141: case 140: - case 139: return ScriptElementKind.memberFunctionElement; + case 139: case 138: - case 137: return ScriptElementKind.memberVariableElement; - case 146: return ScriptElementKind.indexSignatureElement; - case 145: return ScriptElementKind.constructSignatureElement; - case 144: return ScriptElementKind.callSignatureElement; - case 141: return ScriptElementKind.constructorImplementationElement; - case 134: return ScriptElementKind.typeParameterElement; - case 244: return ScriptElementKind.variableElement; - case 135: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218: - case 223: - case 220: - case 227: + case 147: return ScriptElementKind.indexSignatureElement; + case 146: return ScriptElementKind.constructSignatureElement; + case 145: return ScriptElementKind.callSignatureElement; + case 142: return ScriptElementKind.constructorImplementationElement; + case 135: return ScriptElementKind.typeParameterElement; + case 245: return ScriptElementKind.variableElement; + case 136: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219: + case 224: case 221: + case 228: + case 222: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -35573,17 +36595,33 @@ var ts; } var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); if (program) { var oldSourceFiles = program.getSourceFiles(); for (var _i = 0; _i < oldSourceFiles.length; _i++) { @@ -35671,44 +36709,44 @@ var ts; return false; } switch (node.kind) { - case 218: + case 219: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211: + case 212: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240: + case 241: var heritageClause = node; - if (heritageClause.token === 103) { + if (heritageClause.token === 104) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212: + case 213: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 216: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213: + case 214: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: - case 210: + case 211: + case 172: + case 211: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -35716,20 +36754,20 @@ var ts; return true; } break; - case 190: + case 191: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208: + case 209: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165: case 166: + case 167: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -35737,7 +36775,7 @@ var ts; return true; } break; - case 135: + case 136: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -35753,17 +36791,17 @@ var ts; return true; } break; - case 138: + case 139: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168: + case 169: 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 136: + case 137: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -35789,17 +36827,17 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109: - case 107: + case 110: case 108: - case 119: + case 109: + case 120: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 110: - case 79: - case 71: - case 74: - case 112: + case 111: + case 80: + case 72: + case 75: + case 113: } } } @@ -35873,13 +36911,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20) { - if (parent_10.kind === 163) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21) { + if (parent_9.kind === 164) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132) { + else if (parent_9.kind === 133) { node = contextToken.parent.left; isRightOfDot = true; } @@ -35887,7 +36925,7 @@ var ts; return undefined; } } - else if (kind === 24 && sourceFile.languageVariant === 1) { + else if (kind === 25 && sourceFile.languageVariant === 1) { isRightOfOpenTag = true; location = contextToken; } @@ -35920,7 +36958,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 || node.kind === 132 || node.kind === 163) { + if (node.kind === 67 || node.kind === 133 || node.kind === 164) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -35966,7 +37004,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231) || (jsxContainer.kind === 232)) { + if ((jsxContainer.kind === 232) || (jsxContainer.kind === 233)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -36008,41 +37046,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23: - return containingNodeKind === 165 - || containingNodeKind === 141 - || containingNodeKind === 166 - || containingNodeKind === 161 - || containingNodeKind === 178 - || containingNodeKind === 149; - case 16: - return containingNodeKind === 165 - || containingNodeKind === 141 - || containingNodeKind === 166 - || containingNodeKind === 169 - || containingNodeKind === 157; - case 18: - return containingNodeKind === 161 - || containingNodeKind === 146 - || containingNodeKind === 133; - case 122: + case 24: + return containingNodeKind === 166 + || containingNodeKind === 142 + || containingNodeKind === 167 + || containingNodeKind === 162 + || containingNodeKind === 179 + || containingNodeKind === 150; + case 17: + return containingNodeKind === 166 + || containingNodeKind === 142 + || containingNodeKind === 167 + || containingNodeKind === 170 + || containingNodeKind === 158; + case 19: + return containingNodeKind === 162 + || containingNodeKind === 147 + || containingNodeKind === 134; case 123: + case 124: return true; - case 20: - return containingNodeKind === 215; - case 14: - return containingNodeKind === 211; - case 54: - return containingNodeKind === 208 - || containingNodeKind === 178; - case 11: - return containingNodeKind === 180; + case 21: + return containingNodeKind === 216; + case 15: + return containingNodeKind === 212; + case 55: + return containingNodeKind === 209 + || containingNodeKind === 179; case 12: - return containingNodeKind === 187; - case 109: - case 107: + return containingNodeKind === 181; + case 13: + return containingNodeKind === 188; + case 110: case 108: - return containingNodeKind === 138; + case 109: + return containingNodeKind === 139; } switch (previousToken.getText()) { case "public": @@ -36054,8 +37092,8 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 - || contextToken.kind === 9 + if (contextToken.kind === 9 + || contextToken.kind === 10 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -36064,7 +37102,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9; + || contextToken.kind === 10; } } return false; @@ -36073,15 +37111,23 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162) { + if (objectLikeContainer.kind === 163) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158) { + else if (objectLikeContainer.kind === 159) { isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -36096,9 +37142,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 ? - 219 : - 225; + var declarationKind = namedImportsOrExports.kind === 223 ? + 220 : + 226; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -36117,11 +37163,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14: - case 23: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 || parent_11.kind === 158)) { - return parent_11; + case 15: + case 24: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 || parent_10.kind === 159)) { + return parent_10; } break; } @@ -36131,11 +37177,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14: - case 23: + case 15: + case 24: switch (contextToken.parent.kind) { - case 222: - case 226: + case 223: + case 227: return contextToken.parent; } } @@ -36144,21 +37190,31 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25: - case 37: - case 66: - if (parent_12 && (parent_12.kind === 231 || parent_12.kind === 232)) { - return parent_12; + case 26: + case 38: + case 67: + case 236: + case 237: + if (parent_11 && (parent_11.kind === 232 || parent_11.kind === 233)) { + return parent_11; } break; - case 15: - if (parent_12 && - parent_12.kind === 237 && - parent_12.parent && - parent_12.parent.kind === 235) { - return parent_12.parent.parent; + case 9: + if (parent_11 && ((parent_11.kind === 236) || (parent_11.kind === 237))) { + return parent_11.parent; + } + break; + case 16: + if (parent_11 && + parent_11.kind === 238 && + parent_11.parent && + (parent_11.parent.kind === 236)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237) { + return parent_11.parent; } break; } @@ -36167,16 +37223,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170: case 171: - case 210: + case 172: + case 211: + case 141: case 140: - case 139: - case 142: case 143: case 144: case 145: case 146: + case 147: return true; } return false; @@ -36184,65 +37240,65 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23: - return containingNodeKind === 208 || - containingNodeKind === 209 || - containingNodeKind === 190 || - containingNodeKind === 214 || - isFunction(containingNodeKind) || - containingNodeKind === 211 || - containingNodeKind === 210 || - containingNodeKind === 212 || - containingNodeKind === 159; - case 20: - return containingNodeKind === 159; - case 52: - return containingNodeKind === 160; - case 18: - return containingNodeKind === 159; - case 16: - return containingNodeKind === 241 || - isFunction(containingNodeKind); - case 14: - return containingNodeKind === 214 || - containingNodeKind === 212 || - containingNodeKind === 152; - case 22: - return containingNodeKind === 137 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 || - contextToken.parent.parent.kind === 152); case 24: - return containingNodeKind === 211 || + return containingNodeKind === 209 || containingNodeKind === 210 || + containingNodeKind === 191 || + containingNodeKind === 215 || + isFunction(containingNodeKind) || containingNodeKind === 212 || - isFunction(containingNodeKind); - case 110: - return containingNodeKind === 138; + containingNodeKind === 211 || + containingNodeKind === 213 || + containingNodeKind === 160; case 21: - return containingNodeKind === 135 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159); - case 109: - case 107: - case 108: - return containingNodeKind === 135; - case 113: - containingNodeKind === 223 || - containingNodeKind === 227 || - containingNodeKind === 221; - case 70: - case 78: - case 104: - case 84: - case 99: - case 120: - case 126: - case 86: - case 105: - case 71: + return containingNodeKind === 160; + case 53: + return containingNodeKind === 161; + case 19: + return containingNodeKind === 160; + case 17: + return containingNodeKind === 242 || + isFunction(containingNodeKind); + case 15: + return containingNodeKind === 215 || + containingNodeKind === 213 || + containingNodeKind === 153; + case 23: + return containingNodeKind === 138 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 213 || + contextToken.parent.parent.kind === 153); + case 25: + return containingNodeKind === 212 || + containingNodeKind === 211 || + containingNodeKind === 213 || + isFunction(containingNodeKind); case 111: - case 129: + return containingNodeKind === 139; + case 22: + return containingNodeKind === 136 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 160); + case 110: + case 108: + case 109: + return containingNodeKind === 136; + case 114: + containingNodeKind === 224 || + containingNodeKind === 228 || + containingNodeKind === 222; + case 71: + case 79: + case 105: + case 85: + case 100: + case 121: + case 127: + case 87: + case 106: + case 72: + case 112: + case 130: return true; } switch (contextToken.getText()) { @@ -36260,7 +37316,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7) { + if (contextToken.kind === 8) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -36288,16 +37344,16 @@ var ts; var existingMemberNames = {}; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; - if (m.kind !== 242 && - m.kind !== 243 && - m.kind !== 160) { + if (m.kind !== 243 && + m.kind !== 244 && + m.kind !== 161) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 160 && m.propertyName) { + if (m.kind === 161 && m.propertyName) { existingName = m.propertyName.text; } else { @@ -36314,7 +37370,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235) { + if (attr.kind === 236) { seenNames[attr.name.text] = true; } } @@ -36434,7 +37490,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 183) ? + return ts.getDeclarationOfKind(symbol, 184) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -36530,14 +37586,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163) { + if (location.parent && location.parent.kind === 164) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 165 || location.kind === 166) { + if (location.kind === 166 || location.kind === 167) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -36549,7 +37605,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 || callExpression.expression.kind === 92; + var useConstructSignatures = callExpression.kind === 167 || callExpression.expression.kind === 93; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -36564,7 +37620,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -36579,10 +37635,10 @@ var ts; case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(52)); + displayParts.push(ts.punctuationPart(53)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536)) { @@ -36597,21 +37653,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 118 && location.parent.kind === 141)) { + (location.kind === 119 && location.parent.kind === 142)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141) { + if (functionDeclaration.kind === 142) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -36620,11 +37676,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183)) { + if (ts.getDeclarationOfKind(symbol, 184)) { pushTypePart(ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(70)); + displayParts.push(ts.keywordPart(71)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -36632,61 +37688,61 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104)); + displayParts.push(ts.keywordPart(105)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129)); + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71)); + displayParts.push(ts.keywordPart(72)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78)); + displayParts.push(ts.keywordPart(79)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66; - displayParts.push(ts.keywordPart(isNamespace ? 123 : 122)); + var declaration = ts.getDeclarationOfKind(symbol, 216); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67; + displayParts.push(ts.keywordPart(isNamespace ? 124 : 123)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(18)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145) { - displayParts.push(ts.keywordPart(89)); + if (signatureDeclaration.kind === 146) { + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 144 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); @@ -36695,11 +37751,11 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244) { + if (declaration.kind === 245) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -36707,26 +37763,26 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86)); + displayParts.push(ts.keywordPart(87)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218) { + if (declaration.kind === 219) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124)); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(125)); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(18)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -36742,7 +37798,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52)); + displayParts.push(ts.punctuationPart(53)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -36800,9 +37856,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(18)); return; } } @@ -36810,12 +37866,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.operatorPart(34)); + displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.operatorPart(35)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.punctuationPart(18)); } documentation = signature.getDocumentationComment(); } @@ -36840,11 +37896,11 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 66: - case 163: - case 132: - case 94: - case 92: + case 67: + case 164: + case 133: + case 95: + case 93: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -36893,10 +37949,10 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 118) { + if (isNewExpressionTarget(location) || location.kind === 119) { if (symbol.flags & 32) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 212); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -36912,8 +37968,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141) || - (!selectConstructors && (d.kind === 210 || d.kind === 140 || d.kind === 139))) { + if ((selectConstructors && d.kind === 142) || + (!selectConstructors && (d.kind === 211 || d.kind === 141 || d.kind === 140))) { declarations.push(d); if (d.body) definition = d; @@ -36964,11 +38020,11 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 66 && node.parent === declaration) { + if (node.kind === 67 && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 243) { + if (node.parent.kind === 244) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -37039,9 +38095,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 || - node.kind === 94 || - node.kind === 92 || + if (node.kind === 67 || + node.kind === 95 || + node.kind === 93 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); @@ -37090,77 +38146,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85: - case 77: - if (hasKind(node.parent, 193)) { + case 86: + case 78: + if (hasKind(node.parent, 194)) { return getIfElseOccurrences(node.parent); } break; - case 91: - if (hasKind(node.parent, 201)) { + case 92: + if (hasKind(node.parent, 202)) { return getReturnOccurrences(node.parent); } break; - case 95: - if (hasKind(node.parent, 205)) { + case 96: + if (hasKind(node.parent, 206)) { return getThrowOccurrences(node.parent); } break; - case 69: - if (hasKind(parent(parent(node)), 206)) { + case 70: + if (hasKind(parent(parent(node)), 207)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97: - case 82: - if (hasKind(parent(node), 206)) { + case 98: + case 83: + if (hasKind(parent(node), 207)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93: - if (hasKind(node.parent, 203)) { + case 94: + if (hasKind(node.parent, 204)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68: - case 74: - if (hasKind(parent(parent(parent(node))), 203)) { + case 69: + case 75: + if (hasKind(parent(parent(parent(node))), 204)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67: - case 72: - if (hasKind(node.parent, 200) || hasKind(node.parent, 199)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68: + case 73: + if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83: - if (hasKind(node.parent, 196) || - hasKind(node.parent, 197) || - hasKind(node.parent, 198)) { + case 84: + if (hasKind(node.parent, 197) || + hasKind(node.parent, 198) || + hasKind(node.parent, 199)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101: - case 76: - if (hasKind(node.parent, 195) || hasKind(node.parent, 194)) { + case 102: + case 77: + if (hasKind(node.parent, 196) || hasKind(node.parent, 195)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118: - if (hasKind(node.parent, 141)) { + case 119: + if (hasKind(node.parent, 142)) { return getConstructorOccurrences(node.parent); } break; - case 120: - case 126: - if (hasKind(node.parent, 142) || hasKind(node.parent, 143)) { + case 121: + case 127: + if (hasKind(node.parent, 143) || hasKind(node.parent, 144)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -37172,10 +38228,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205) { + if (node.kind === 206) { statementAccumulator.push(node); } - else if (node.kind === 206) { + else if (node.kind === 207) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -37196,17 +38252,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246) { + return parent_12; } - if (parent_13.kind === 206) { - var tryStatement = parent_13; + if (parent_12.kind === 207) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -37215,7 +38271,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 || node.kind === 199) { + if (node.kind === 201 || node.kind === 200) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -37231,15 +38287,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203: - if (statement.kind === 199) { + case 204: + if (statement.kind === 200) { continue; } - case 196: case 197: case 198: + case 199: + case 196: case 195: - case 194: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -37256,24 +38312,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 || - container.kind === 183 || - (declaration.kind === 135 && hasKind(container, 141)))) { + if (!(container.kind === 212 || + container.kind === 184 || + (declaration.kind === 136 && hasKind(container, 142)))) { return undefined; } } - else if (modifier === 110) { - if (!(container.kind === 211 || container.kind === 183)) { + else if (modifier === 111) { + if (!(container.kind === 212 || container.kind === 184)) { return undefined; } } - else if (modifier === 79 || modifier === 119) { - if (!(container.kind === 216 || container.kind === 245)) { + else if (modifier === 80 || modifier === 120) { + if (!(container.kind === 217 || container.kind === 246)) { return undefined; } } - else if (modifier === 112) { - if (!(container.kind === 211 || declaration.kind === 211)) { + else if (modifier === 113) { + if (!(container.kind === 212 || declaration.kind === 212)) { return undefined; } } @@ -37284,8 +38340,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216: - case 245: + case 217: + case 246: if (modifierFlag & 256) { nodes = declaration.members.concat(declaration); } @@ -37293,15 +38349,15 @@ var ts; nodes = container.statements; } break; - case 141: + case 142: nodes = container.parameters.concat(container.parent.members); break; - case 211: - case 183: + case 212: + case 184: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 && member; + return member.kind === 142 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -37322,19 +38378,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109: - return 16; - case 107: - return 32; - case 108: - return 64; case 110: + return 16; + case 108: + return 32; + case 109: + return 64; + case 111: return 128; - case 79: + case 80: return 1; - case 119: + case 120: return 2; - case 112: + case 113: return 256; default: ts.Debug.fail(); @@ -37354,13 +38410,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142); tryPushAccessorKeyword(accessorDeclaration.symbol, 143); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144); 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, 120, 126); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121, 127); }); } } } @@ -37369,18 +38425,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118); + return pushKeywordIf(keywords, token, 119); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83, 101, 76)) { - if (loopNode.kind === 194) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84, 102, 77)) { + if (loopNode.kind === 195) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101)) { + if (pushKeywordIf(keywords, loopTokens[i], 102)) { break; } } @@ -37389,22 +38445,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67, 72); + pushKeywordIf(keywords, statement.getFirstToken(), 68, 73); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return getLoopBreakContinueOccurrences(owner); - case 203: + case 204: return getSwitchCaseDefaultOccurrences(owner); } } @@ -37412,13 +38468,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68, 74); + pushKeywordIf(keywords, clause.getFirstToken(), 69, 75); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67); + pushKeywordIf(keywords, statement.getFirstToken(), 68); } }); }); @@ -37426,13 +38482,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83); } return ts.map(keywords, getHighlightSpanForNode); } @@ -37443,50 +38499,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 189))) { + if (!(func && hasKind(func.body, 190))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 193) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85); + pushKeywordIf(keywords, children[0], 86); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77)) { + if (pushKeywordIf(keywords, children[i], 78)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193)) { + if (!hasKind(ifStatement.elseStatement, 194)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 && i < keywords.length - 1) { + if (keywords[i].kind === 78 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -37564,12 +38620,12 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 && + if (node.kind !== 67 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 || node.kind === 7 || node.kind === 8); + ts.Debug.assert(node.kind === 67 || node.kind === 8 || node.kind === 9); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -37583,10 +38639,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94) { + if (node.kind === 95) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92) { + if (node.kind === 93) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -37637,7 +38693,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 || declaration.kind === 227; + return declaration.kind === 224 || declaration.kind === 228; }); } function getInternedName(symbol, location, declarations) { @@ -37650,13 +38706,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 || valueDeclaration.kind === 183)) { + if (valueDeclaration && (valueDeclaration.kind === 171 || valueDeclaration.kind === 184)) { return valueDeclaration; } 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, 211); + return ts.getAncestor(privateDeclaration, 212); } } if (symbol.flags & 8388608) { @@ -37677,7 +38733,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 245 && !ts.isExternalModule(container)) { + if (container.kind === 246 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -37736,15 +38792,15 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 66: + case 67: return node.getWidth() === searchSymbolName.length; - case 8: + case 9: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { return node.getWidth() === searchSymbolName.length + 2; } break; - case 7: + case 8: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -37763,8 +38819,8 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { result.push({ definition: undefined, references: [{ @@ -37809,24 +38865,12 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { @@ -37836,13 +38880,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -37855,7 +38899,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92) { + if (!node || node.kind !== 93) { return; } var container = ts.getSuperContainer(node, false); @@ -37870,32 +38914,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { + case 141: case 140: - case 139: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 139: case 138: - case 137: - case 141: case 142: case 143: + case 144: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 245: + case 246: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 210: - case 170: + case 211: + case 171: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245) { + if (searchSpaceNode.kind === 246) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -37921,30 +38965,30 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94) { + if (!node || node.kind !== 95) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 170: - case 210: + case 171: + case 211: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 141: case 140: - case 139: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211: + case 212: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 245: - if (container.kind === 245 && !ts.isExternalModule(container)) { + case 246: + if (container.kind === 246 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -37979,11 +39023,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 211) { + if (declaration.kind === 212) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212) { + else if (declaration.kind === 213) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -38081,7 +39125,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8) { + if (node.kind === 9) { start += 1; end -= 1; } @@ -38092,17 +39136,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 66 && ts.isDeclarationName(node)) { + if (node.kind === 67 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 || parent.kind === 176) { + if (parent.kind === 178 || parent.kind === 177) { return true; } - else if (parent.kind === 178 && parent.left === node) { + else if (parent.kind === 179 && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 <= operator && operator <= 65; + return 55 <= operator && operator <= 66; } } return false; @@ -38133,34 +39177,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135: - case 208: - case 160: + case 136: + case 209: + case 161: + case 139: case 138: - case 137: - case 242: case 243: case 244: - case 140: - case 139: + case 245: case 141: + case 140: case 142: case 143: - case 210: - case 170: - case 171: - case 241: - return 1; - case 134: - case 212: - case 213: - case 152: - return 2; + case 144: case 211: + case 171: + case 172: + case 242: + return 1; + case 135: + case 213: case 214: - return 1 | 2; + case 153: + return 2; + case 212: case 215: - if (node.name.kind === 8) { + return 1 | 2; + case 216: + if (node.name.kind === 9) { return 4 | 1; } else if (ts.getModuleInstanceState(node) === 1) { @@ -38169,14 +39213,14 @@ var ts; else { return 4; } - case 222: case 223: - case 218: - case 219: case 224: + case 219: + case 220: case 225: + case 226: return 1 | 2 | 4; - case 245: + case 246: return 4 | 1; } return 1 | 2 | 4; @@ -38186,8 +39230,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 || - (node.parent.kind === 185 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 || + (node.parent.kind === 186 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -38195,47 +39239,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163) { - while (root.parent && root.parent.kind === 163) { + if (root.parent.kind === 164) { + while (root.parent && root.parent.kind === 164) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 && root.parent.parent.kind === 240) { + if (!isLastClause && root.parent.kind === 186 && root.parent.parent.kind === 241) { var decl = root.parent.parent.parent; - return (decl.kind === 211 && root.parent.parent.token === 103) || - (decl.kind === 212 && root.parent.parent.token === 80); + return (decl.kind === 212 && root.parent.parent.token === 104) || + (decl.kind === 213 && root.parent.parent.token === 81); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132) { - while (root.parent && root.parent.kind === 132) { + if (root.parent.kind === 133) { + while (root.parent && root.parent.kind === 133) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 && !isLastClause; + return root.parent.kind === 149 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132) { + while (node.parent.kind === 133) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66); - if (node.parent.kind === 132 && + ts.Debug.assert(node.kind === 67); + if (node.parent.kind === 133 && node.parent.right === node && - node.parent.parent.kind === 218) { + node.parent.parent.kind === 219) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224) { + if (node.parent.kind === 225) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -38269,15 +39313,15 @@ var ts; return; } switch (node.kind) { - case 163: - case 132: - case 8: - case 81: - case 96: - case 90: - case 92: - case 94: - case 66: + case 164: + case 133: + case 9: + case 82: + case 97: + case 91: + case 93: + case 95: + case 67: break; default: return; @@ -38288,7 +39332,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 215 && + if (nodeForStartPos.parent.parent.kind === 216 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -38315,10 +39359,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } @@ -38366,7 +39410,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 && + return declaration.kind === 216 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -38375,7 +39419,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 && !ts.nodeIsMissing(node)) { + if (kind === 67 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -38462,7 +39506,7 @@ var ts; triviaScanner.setTextPos(end); continue; } - if (kind === 6) { + if (kind === 7) { var text = sourceFile.text; var ch = text.charCodeAt(start); if (ch === 60 || ch === 62) { @@ -38499,16 +39543,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 264: + case 265: processJSDocParameterTag(tag); break; - case 267: + case 268: processJSDocTemplateTag(tag); break; - case 266: + case 267: processElement(tag.typeExpression); break; - case 265: + case 266: processElement(tag.typeExpression); break; } @@ -38581,70 +39625,70 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 24 || tokenKind === 26) { + if (tokenKind === 25 || tokenKind === 27) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54) { - if (token.parent.kind === 208 || - token.parent.kind === 138 || - token.parent.kind === 135) { + if (tokenKind === 55) { + if (token.parent.kind === 209 || + token.parent.kind === 139 || + token.parent.kind === 136) { return 5; } } - if (token.parent.kind === 178 || - token.parent.kind === 176 || + if (token.parent.kind === 179 || token.parent.kind === 177 || - token.parent.kind === 179) { + token.parent.kind === 178 || + token.parent.kind === 180) { return 5; } } return 10; } - else if (tokenKind === 7) { + else if (tokenKind === 8) { return 4; } - else if (tokenKind === 8) { + else if (tokenKind === 9) { return 6; } - else if (tokenKind === 9) { + else if (tokenKind === 10) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 66) { + else if (tokenKind === 67) { if (token) { switch (token.parent.kind) { - case 211: + case 212: if (token.parent.name === token) { return 11; } return; - case 134: + case 135: if (token.parent.name === token) { return 15; } return; - case 212: + case 213: if (token.parent.name === token) { return 13; } return; - case 214: + case 215: if (token.parent.name === token) { return 12; } return; - case 215: + case 216: if (token.parent.name === token) { return 14; } return; - case 135: + case 136: if (token.parent.name === token) { return 17; } @@ -38705,14 +39749,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14: return 15; - case 16: return 17; - case 18: return 19; - case 24: return 26; - case 15: return 14; - case 17: return 16; - case 19: return 18; - case 26: return 24; + case 15: return 16; + case 17: return 18; + case 19: return 20; + case 25: return 27; + case 16: return 15; + case 18: return 17; + case 20: return 19; + case 27: return 25; } return undefined; } @@ -38747,6 +39791,38 @@ var ts; } return []; } + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + var containingFunction = ts.getAncestor(tokenAtPos, 211); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 ? cur.name.text : "param" + index) + newLine; + }, ""); + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -38813,7 +39889,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 66) { + if (node && node.kind === 67) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -38891,6 +39967,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -38910,13 +39987,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66: + case 67: nameTable[node.text] = node.text; break; + case 9: case 8: - case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 229 || + node.parent.kind === 230 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -38929,31 +40006,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 && + node.parent.kind === 165 && node.parent.argumentExpression === node; } function createClassifier() { var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[66] = true; - noRegexTable[8] = true; - noRegexTable[7] = true; + noRegexTable[67] = true; noRegexTable[9] = true; - noRegexTable[94] = true; - noRegexTable[39] = true; + noRegexTable[8] = true; + noRegexTable[10] = true; + noRegexTable[95] = true; noRegexTable[40] = true; - noRegexTable[17] = true; - noRegexTable[19] = true; - noRegexTable[15] = true; - noRegexTable[96] = true; - noRegexTable[81] = true; + noRegexTable[41] = true; + noRegexTable[18] = true; + noRegexTable[20] = true; + noRegexTable[16] = true; + noRegexTable[97] = true; + noRegexTable[82] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 || - keyword2 === 126 || - keyword2 === 118 || - keyword2 === 110) { + if (keyword2 === 121 || + keyword2 === 127 || + keyword2 === 119 || + keyword2 === 111) { return true; } return false; @@ -38966,7 +40043,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; @@ -38974,8 +40051,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -39036,7 +40113,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(11); + templateStack.push(12); break; } scanner.setText(text); @@ -39048,55 +40125,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 || token === 58) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9) { - token = 9; + if ((token === 38 || token === 59) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10) { + token = 10; } } - else if (lastNonTriviaToken === 20 && isKeyword(token)) { - token = 66; + else if (lastNonTriviaToken === 21 && isKeyword(token)) { + token = 67; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 66; + token = 67; } - else if (lastNonTriviaToken === 66 && - token === 24) { + else if (lastNonTriviaToken === 67 && + token === 25) { angleBracketStack++; } - else if (token === 26 && angleBracketStack > 0) { + else if (token === 27 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 114 || - token === 127 || - token === 125 || - token === 117 || - token === 128) { + else if (token === 115 || + token === 128 || + token === 126 || + token === 118 || + token === 129) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 66; + token = 67; } } - else if (token === 11) { + else if (token === 12) { templateStack.push(token); } - else if (token === 14) { + else if (token === 15) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15) { + else if (token === 16) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11) { + if (lastTemplateStackToken === 12) { token = scanner.reScanTemplateToken(); - if (token === 13) { + if (token === 14) { templateStack.pop(); } else { - ts.Debug.assert(token === 12, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -39111,7 +40188,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8) { + if (token === 9) { var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; @@ -39134,10 +40211,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13) { + if (token === 14) { result.endOfLineState = 5; } - else if (token === 10) { + else if (token === 11) { result.endOfLineState = 4; } else { @@ -39145,7 +40222,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { result.endOfLineState = 6; } } @@ -39169,42 +40246,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36: case 37: case 38: - case 34: + case 39: case 35: - case 41: + case 36: case 42: case 43: - case 24: - case 26: + case 44: + case 25: case 27: case 28: - case 88: - case 87: case 29: + case 89: + case 88: case 30: case 31: case 32: - case 44: - case 46: + case 33: case 45: - case 49: + case 47: + case 46: case 50: - case 64: - case 63: + case 51: case 65: - case 60: + case 64: + case 66: case 61: case 62: - case 55: + case 63: case 56: case 57: case 58: case 59: - case 54: - case 23: + case 60: + case 55: + case 24: return true; default: return false; @@ -39212,19 +40289,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return true; default: return false; } } function isKeyword(token) { - return token >= 67 && token <= 131; + return token >= 68 && token <= 132; } function classFromKind(token) { if (isKeyword(token)) { @@ -39233,24 +40310,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 14 && token <= 65) { + else if (token >= 15 && token <= 66) { return 10; } switch (token) { - case 7: - return 4; case 8: - return 6; + return 4; case 9: + return 6; + case 10: return 7; - case 6: + case 7: case 3: case 2: return 1; case 5: case 4: return 8; - case 66: + case 67: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -39276,7 +40353,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -39366,9 +40443,11 @@ var ts; CommandNames.Format = "format"; CommandNames.Formatonkey = "formatonkey"; CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; CommandNames.NavBar = "navbar"; CommandNames.Navto = "navto"; CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; CommandNames.Open = "open"; CommandNames.Quickinfo = "quickinfo"; CommandNames.References = "references"; @@ -39378,6 +40457,7 @@ var ts; CommandNames.SignatureHelp = "signatureHelp"; CommandNames.TypeDefinition = "typeDefinition"; CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; CommandNames.Unknown = "unknown"; })(CommandNames = server.CommandNames || (server.CommandNames = {})); var Errors; @@ -39398,57 +40478,61 @@ var ts; this.handlers = (_a = {}, _a[CommandNames.Exit] = function () { _this.exit(); - return {}; + return { responseRequired: false }; }, _a[CommandNames.Definition] = function (request) { var defArgs = request.arguments; - return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.TypeDefinition] = function (request) { var defArgs = request.arguments; - return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.References] = function (request) { var defArgs = request.arguments; - return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.Rename] = function (request) { var renameArgs = request.arguments; - return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings) }; + return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true }; }, _a[CommandNames.Open] = function (request) { var openArgs = request.arguments; _this.openClientFile(openArgs.file); - return {}; + return { responseRequired: false }; }, _a[CommandNames.Quickinfo] = function (request) { var quickinfoArgs = request.arguments; - return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file) }; + return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true }; }, _a[CommandNames.Format] = function (request) { var formatArgs = request.arguments; - return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file) }; + return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true }; }, _a[CommandNames.Formatonkey] = function (request) { var formatOnKeyArgs = request.arguments; - return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file) }; + return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true }; }, _a[CommandNames.Completions] = function (request) { var completionsArgs = request.arguments; - return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file) }; + return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true }; }, _a[CommandNames.CompletionDetails] = function (request) { var completionDetailsArgs = request.arguments; - return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file) }; + return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true }; }, _a[CommandNames.SignatureHelp] = function (request) { var signatureHelpArgs = request.arguments; - return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file) }; + return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; }, _a[CommandNames.Geterr] = function (request) { var geterrArgs = request.arguments; return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; }, + _a[CommandNames.GeterrForProject] = function (request) { + var _a = request.arguments, file = _a.file, delay = _a.delay; + return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; + }, _a[CommandNames.Change] = function (request) { var changeArgs = request.arguments; _this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); @@ -39477,23 +40561,31 @@ var ts; }, _a[CommandNames.Navto] = function (request) { var navtoArgs = request.arguments; - return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount) }; + return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true }; }, _a[CommandNames.Brace] = function (request) { var braceArguments = request.arguments; - return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file) }; + return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true }; }, _a[CommandNames.NavBar] = function (request) { var navBarArgs = request.arguments; - return { response: _this.getNavigationBarItems(navBarArgs.file) }; + return { response: _this.getNavigationBarItems(navBarArgs.file), responseRequired: true }; }, _a[CommandNames.Occurrences] = function (request) { var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; - return { response: _this.getOccurrences(line, offset, fileName) }; + return { response: _this.getOccurrences(line, offset, fileName), responseRequired: true }; + }, + _a[CommandNames.DocumentHighlights] = function (request) { + var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file, filesToSearch = _a.filesToSearch; + return { response: _this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true }; }, _a[CommandNames.ProjectInfo] = function (request) { var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; - return { response: _this.getProjectInfo(file, needFileNameList) }; + return { response: _this.getProjectInfo(file, needFileNameList), responseRequired: true }; + }, + _a[CommandNames.ReloadProjects] = function (request) { + _this.reloadProjects(); + return { responseRequired: false }; }, _a ); @@ -39590,6 +40682,9 @@ var ts; this.syntacticCheck(file, project); this.semanticCheck(file, project); }; + Session.prototype.reloadProjects = function () { + this.projectService.reloadProjects(); + }; Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { var _this = this; if (ms === void 0) { ms = 1500; } @@ -39599,10 +40694,11 @@ var ts; } }, ms); }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs) { + Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { var _this = this; if (ms === void 0) { ms = 1500; } if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } if (followMs > ms) { followMs = ms; } @@ -39617,7 +40713,7 @@ var ts; var checkOne = function () { if (matchSeq(seq)) { var checkSpec = checkList[index++]; - if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) { + if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { _this.syntacticCheck(checkSpec.fileName, checkSpec.project); _this.immediateId = setImmediate(function () { _this.semanticCheck(checkSpec.fileName, checkSpec.project); @@ -39696,6 +40792,33 @@ var ts; }; }); }; + Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { + fileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(fileName); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); + var documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); + if (!documentHighlights) { + return undefined; + } + return documentHighlights.map(convertToDocumentHighlightsItem); + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + function convertHighlightSpan(highlightSpan) { + var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; + var start = compilerService.host.positionToLineOffset(fileName, textSpan.start); + var end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + return { start: start, end: end, kind: kind }; + } + } + }; Session.prototype.getProjectInfo = function (fileName, needFileNameList) { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); @@ -39703,7 +40826,7 @@ var ts; configFileName: project.projectFilename }; if (needFileNameList) { - projectInfo.fileNameList = project.getFileNameList(); + projectInfo.fileNames = project.getFileNames(); } return projectInfo; }; @@ -40116,6 +41239,45 @@ var ts; end: compilerService.host.positionToLineOffset(file, span.start + span.length) }); }); }; + Session.prototype.getDiagnosticsForProject = function (delay, fileName) { + var _this = this; + var _a = this.getProjectInfo(fileName, true), configFileName = _a.configFileName, fileNamesInProject = _a.fileNames; + fileNamesInProject = fileNamesInProject.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); + var highPriorityFiles = []; + var mediumPriorityFiles = []; + var lowPriorityFiles = []; + var veryLowPriorityFiles = []; + var normalizedFileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(normalizedFileName); + for (var _i = 0; _i < fileNamesInProject.length; _i++) { + var fileNameInProject = fileNamesInProject[_i]; + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + var info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isOpen) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); + } + } + fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); + if (fileNamesInProject.length > 0) { + var checkList = fileNamesInProject.map(function (fileName) { + var normalizedFileName = ts.normalizePath(fileName); + return { fileName: normalizedFileName, project: project }; + }); + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + } + }; + Session.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; Session.prototype.exit = function () { }; Session.prototype.addProtocolHandler = function (command, handler) { @@ -40238,12 +41400,52 @@ var ts; server.ScriptInfo = ScriptInfo; var LSHost = (function () { function LSHost(host, project) { + var _this = this; this.host = host; this.project = project; this.ls = null; this.filenameToScript = {}; this.roots = []; + this.resolvedModuleNames = ts.createFileMap(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.moduleResolutionHost = { + fileExists: function (fileName) { return _this.fileExists(fileName); }, + readFile: function (fileName) { return _this.host.readFile(fileName); } + }; } + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + var newResolutions = {}; + var resolvedFileNames = []; + var compilerOptions = this.getCompilationSettings(); + for (var _i = 0; _i < moduleNames.length; _i++) { + var moduleName = moduleNames[_i]; + var resolution = ts.lookUp(newResolutions, moduleName); + if (!resolution) { + var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + resolution = ts.resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); + resolution.lastCheckTime = Date.now(); + newResolutions[moduleName] = resolution; + } + } + ts.Debug.assert(resolution !== undefined); + resolvedFileNames.push(resolution.resolvedFileName); + } + this.resolvedModuleNames.set(containingFile, newResolutions); + return resolvedFileNames; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + if (resolution.resolvedFileName) { + return true; + } + return resolution.failedLookupLocations.length === 0; + } + }; LSHost.prototype.getDefaultLibFileName = function () { var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); @@ -40256,6 +41458,7 @@ var ts; }; LSHost.prototype.setCompilationSettings = function (opt) { this.compilationSettings = opt; + this.resolvedModuleNames.clear(); }; LSHost.prototype.lineAffectsRefs = function (filename, line) { var info = this.getScriptInfo(filename); @@ -40283,6 +41486,7 @@ var ts; LSHost.prototype.removeReferencedFile = function (info) { if (!info.isOpen) { this.filenameToScript[info.fileName] = undefined; + this.resolvedModuleNames.remove(info.fileName); } }; LSHost.prototype.getScriptInfo = function (filename) { @@ -40304,6 +41508,13 @@ var ts; this.roots.push(info); } }; + LSHost.prototype.removeRoot = function (info) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (scriptInfo) { + this.filenameToScript[info.fileName] = undefined; + this.roots = copyListRemovingItem(info, this.roots); + } + }; LSHost.prototype.saveTo = function (filename, tmpfilename) { var script = this.getScriptInfo(filename); if (script) { @@ -40410,7 +41621,7 @@ var ts; Project.prototype.openReferencedFile = function (filename) { return this.projectService.openFile(filename, false); }; - Project.prototype.getFileNameList = function () { + Project.prototype.getFileNames = function () { var sourceFiles = this.program.getSourceFiles(); return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); }; @@ -40455,6 +41666,10 @@ var ts; info.defaultProject = this; this.compilerService.host.addRoot(info); }; + Project.prototype.removeRoot = function (info) { + info.defaultProject = undefined; + this.compilerService.host.removeRoot(info); + }; Project.prototype.filesToString = function () { var strBuilder = ""; ts.forEachValue(this.filenameToSourceFile, function (sourceFile) { strBuilder += sourceFile.fileName + "\n"; }); @@ -40520,6 +41735,11 @@ var ts; } } }; + ProjectService.prototype.watchedProjectConfigFileChanged = function (project) { + this.log("Config File Changed: " + project.projectFilename); + this.updateConfiguredProject(project); + this.updateProjectStructure(); + }; ProjectService.prototype.log = function (msg, type) { if (type === void 0) { type = "Err"; } this.psLogger.msg(msg, type); @@ -40589,6 +41809,18 @@ var ts; } this.configuredProjects = configuredProjects; }; + ProjectService.prototype.removeConfiguredProject = function (project) { + project.projectFileWatcher.close(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + var fileNames = project.getFileNames(); + for (var _i = 0; _i < fileNames.length; _i++) { + var fileName = fileNames[_i]; + var info = this.getScriptInfo(fileName); + if (info.defaultProject == project) { + info.defaultProject = undefined; + } + } + }; ProjectService.prototype.setConfiguredProjectRoot = function (info) { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { var configuredProject = this.configuredProjects[i]; @@ -40707,11 +41939,31 @@ var ts; } return referencingProjects; }; + ProjectService.prototype.reloadProjects = function () { + for (var _i = 0, _a = this.openFileRoots; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.updateProjectStructure(); + }; ProjectService.prototype.updateProjectStructure = function () { this.log("updating project structure from ...", "Info"); this.printProjects(); - var openFilesReferenced = []; var unattachedOpenFiles = []; + var openFileRootsConfigured = []; + for (var _i = 0, _a = this.openFileRootsConfigured; _i < _a.length; _i++) { + var info = _a[_i]; + var project = info.defaultProject; + if (!project || !(project.getSourceFile(info))) { + info.defaultProject = undefined; + unattachedOpenFiles.push(info); + } + else { + openFileRootsConfigured.push(info); + } + } + this.openFileRootsConfigured = openFileRootsConfigured; + var openFilesReferenced = []; for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var referencedFile = this.openFilesReferenced[i]; referencedFile.defaultProject.updateGraph(); @@ -40794,32 +42046,36 @@ var ts; return undefined; }; ProjectService.prototype.openClientFile = function (fileName) { + this.openOrUpdateConfiguredProjectForFile(fileName); + var info = this.openFile(fileName, true); + this.addOpenFile(info); + this.printProjects(); + return info; + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { var searchPath = ts.normalizePath(ts.getDirectoryPath(fileName)); this.log("Search path: " + searchPath, "Info"); var configFileName = this.findConfigFile(searchPath); if (configFileName) { this.log("Config file name: " + configFileName, "Info"); - } - else { - this.log("no config file"); - } - if (configFileName) { - configFileName = getAbsolutePath(configFileName, searchPath); - } - if (configFileName && (!this.configProjectIsActive(configFileName))) { - var configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.success) { - this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + var project = this.findConfiguredProjectByConfigFile(configFileName); + if (!project) { + var configResult = this.openConfigFile(configFileName, fileName); + if (!configResult.success) { + this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + } + else { + this.log("Opened configuration file " + configFileName, "Info"); + this.configuredProjects.push(configResult.project); + } } else { - this.log("Opened configuration file " + configFileName, "Info"); - this.configuredProjects.push(configResult.project); + this.updateConfiguredProject(project); } } - var info = this.openFile(fileName, true); - this.addOpenFile(info); - this.printProjects(); - return info; + else { + this.log("No config files found."); + } }; ProjectService.prototype.closeClientFile = function (filename) { var info = ts.lookUp(this.filenameToScriptInfo, filename); @@ -40888,46 +42144,103 @@ var ts; this.psLogger.endGroup(); }; ProjectService.prototype.configProjectIsActive = function (fileName) { + return this.findConfiguredProjectByConfigFile(fileName) === undefined; + }; + ProjectService.prototype.findConfiguredProjectByConfigFile = function (configFileName) { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == fileName) { - return true; + if (this.configuredProjects[i].projectFilename == configFileName) { + return this.configuredProjects[i]; } } - return false; + return undefined; }; - ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { + ProjectService.prototype.configFileToProjectOptions = function (configFilename) { configFilename = ts.normalizePath(configFilename); var dirPath = ts.getDirectoryPath(configFilename); - var rawConfig = ts.readConfigFile(configFilename); + var contents = this.host.readFile(configFilename); + var rawConfig = ts.parseConfigFileText(configFilename, contents); if (rawConfig.error) { - return rawConfig.error; + return { succeeded: false, error: rawConfig.error }; } else { var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { errorMsg: "tsconfig option errors" }; + return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames) { + else if (parsedCommandLine.fileNames == null) { + return { succeeded: false, error: { errorMsg: "no files found" } }; + } + else { var 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 (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, clientFileName == rootFilename); - proj.addRoot(info); - } - else { - return { errorMsg: "specified file " + rootFilename + " not found" }; - } + return { succeeded: true, projectOptions: projectOptions }; + } + } + }; + ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { + var _this = this; + var _a = this.configFileToProjectOptions(configFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; + } + else { + var proj = this.createProject(configFilename, projectOptions); + for (var i = 0, len = projectOptions.files.length; i < len; i++) { + var rootFilename = projectOptions.files[i]; + if (this.host.fileExists(rootFilename)) { + var info = this.openFile(rootFilename, clientFileName == rootFilename); + proj.addRoot(info); } - proj.finishGraph(); - return { success: true, project: proj }; + else { + return { errorMsg: "specified file " + rootFilename + " not found" }; + } + } + proj.finishGraph(); + proj.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(proj); }); + return { success: true, project: proj }; + } + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.projectFilename)) { + this.log("Config file deleted"); + this.removeConfiguredProject(project); + } + else { + var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; } else { - return { errorMsg: "no files found" }; + var oldFileNames = project.compilerService.host.roots.map(function (info) { return info.fileName; }); + var newFileNames = projectOptions.files; + var fileNamesToRemove = oldFileNames.filter(function (f) { return newFileNames.indexOf(f) < 0; }); + var fileNamesToAdd = newFileNames.filter(function (f) { return oldFileNames.indexOf(f) < 0; }); + for (var _i = 0; _i < fileNamesToRemove.length; _i++) { + var fileName = fileNamesToRemove[_i]; + var info = this.getScriptInfo(fileName); + project.removeRoot(info); + } + for (var _b = 0; _b < fileNamesToAdd.length; _b++) { + var fileName = fileNamesToAdd[_b]; + var info = this.getScriptInfo(fileName); + if (!info) { + info = this.openFile(fileName, false); + } + else { + if (this.openFileRoots.indexOf(info) >= 0) { + this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + } + if (this.openFilesReferenced.indexOf(info) >= 0) { + this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + } + this.openFileRootsConfigured.push(info); + } + project.addRoot(info); + } + project.setProjectOptions(projectOptions); + project.finishGraph(); } } }; @@ -40972,6 +42285,7 @@ var ts; InsertSpaceAfterKeywordsInControlFlowStatements: true, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false }; @@ -42081,9 +43395,16 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -42180,10 +43501,22 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -42279,7 +43612,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -42308,9 +43641,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -42419,7 +43749,9 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { @@ -42460,6 +43792,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { var _this = this; return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { @@ -42537,12 +43873,20 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -42659,4 +44003,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 75de230e47b..edeb166cf88 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -23,6 +23,7 @@ declare module "typescript" { contains(fileName: string): boolean; remove(fileName: string): void; forEachValue(f: (v: T) => void): void; + clear(): void; } interface TextRange { pos: number; @@ -35,293 +36,294 @@ declare module "typescript" { MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, - ConflictMarkerTrivia = 6, - NumericLiteral = 7, - StringLiteral = 8, - RegularExpressionLiteral = 9, - NoSubstitutionTemplateLiteral = 10, - TemplateHead = 11, - TemplateMiddle = 12, - TemplateTail = 13, - OpenBraceToken = 14, - CloseBraceToken = 15, - OpenParenToken = 16, - CloseParenToken = 17, - OpenBracketToken = 18, - CloseBracketToken = 19, - DotToken = 20, - DotDotDotToken = 21, - SemicolonToken = 22, - CommaToken = 23, - LessThanToken = 24, - LessThanSlashToken = 25, - GreaterThanToken = 26, - LessThanEqualsToken = 27, - GreaterThanEqualsToken = 28, - EqualsEqualsToken = 29, - ExclamationEqualsToken = 30, - EqualsEqualsEqualsToken = 31, - ExclamationEqualsEqualsToken = 32, - EqualsGreaterThanToken = 33, - PlusToken = 34, - MinusToken = 35, - AsteriskToken = 36, - SlashToken = 37, - PercentToken = 38, - PlusPlusToken = 39, - MinusMinusToken = 40, - LessThanLessThanToken = 41, - GreaterThanGreaterThanToken = 42, - GreaterThanGreaterThanGreaterThanToken = 43, - AmpersandToken = 44, - BarToken = 45, - CaretToken = 46, - ExclamationToken = 47, - TildeToken = 48, - AmpersandAmpersandToken = 49, - BarBarToken = 50, - QuestionToken = 51, - ColonToken = 52, - AtToken = 53, - EqualsToken = 54, - PlusEqualsToken = 55, - MinusEqualsToken = 56, - AsteriskEqualsToken = 57, - SlashEqualsToken = 58, - PercentEqualsToken = 59, - LessThanLessThanEqualsToken = 60, - GreaterThanGreaterThanEqualsToken = 61, - GreaterThanGreaterThanGreaterThanEqualsToken = 62, - AmpersandEqualsToken = 63, - BarEqualsToken = 64, - CaretEqualsToken = 65, - Identifier = 66, - BreakKeyword = 67, - CaseKeyword = 68, - CatchKeyword = 69, - ClassKeyword = 70, - ConstKeyword = 71, - ContinueKeyword = 72, - DebuggerKeyword = 73, - DefaultKeyword = 74, - DeleteKeyword = 75, - DoKeyword = 76, - ElseKeyword = 77, - EnumKeyword = 78, - ExportKeyword = 79, - ExtendsKeyword = 80, - FalseKeyword = 81, - FinallyKeyword = 82, - ForKeyword = 83, - FunctionKeyword = 84, - IfKeyword = 85, - ImportKeyword = 86, - InKeyword = 87, - InstanceOfKeyword = 88, - NewKeyword = 89, - NullKeyword = 90, - ReturnKeyword = 91, - SuperKeyword = 92, - SwitchKeyword = 93, - ThisKeyword = 94, - ThrowKeyword = 95, - TrueKeyword = 96, - TryKeyword = 97, - TypeOfKeyword = 98, - VarKeyword = 99, - VoidKeyword = 100, - WhileKeyword = 101, - WithKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AbstractKeyword = 112, - AsKeyword = 113, - AnyKeyword = 114, - AsyncKeyword = 115, - AwaitKeyword = 116, - BooleanKeyword = 117, - ConstructorKeyword = 118, - DeclareKeyword = 119, - GetKeyword = 120, - IsKeyword = 121, - ModuleKeyword = 122, - NamespaceKeyword = 123, - RequireKeyword = 124, - NumberKeyword = 125, - SetKeyword = 126, - StringKeyword = 127, - SymbolKeyword = 128, - TypeKeyword = 129, - FromKeyword = 130, - OfKeyword = 131, - QualifiedName = 132, - ComputedPropertyName = 133, - TypeParameter = 134, - Parameter = 135, - Decorator = 136, - PropertySignature = 137, - PropertyDeclaration = 138, - MethodSignature = 139, - MethodDeclaration = 140, - Constructor = 141, - GetAccessor = 142, - SetAccessor = 143, - CallSignature = 144, - ConstructSignature = 145, - IndexSignature = 146, - TypePredicate = 147, - TypeReference = 148, - FunctionType = 149, - ConstructorType = 150, - TypeQuery = 151, - TypeLiteral = 152, - ArrayType = 153, - TupleType = 154, - UnionType = 155, - IntersectionType = 156, - ParenthesizedType = 157, - ObjectBindingPattern = 158, - ArrayBindingPattern = 159, - BindingElement = 160, - ArrayLiteralExpression = 161, - ObjectLiteralExpression = 162, - PropertyAccessExpression = 163, - ElementAccessExpression = 164, - CallExpression = 165, - NewExpression = 166, - TaggedTemplateExpression = 167, - TypeAssertionExpression = 168, - ParenthesizedExpression = 169, - FunctionExpression = 170, - ArrowFunction = 171, - DeleteExpression = 172, - TypeOfExpression = 173, - VoidExpression = 174, - AwaitExpression = 175, - PrefixUnaryExpression = 176, - PostfixUnaryExpression = 177, - BinaryExpression = 178, - ConditionalExpression = 179, - TemplateExpression = 180, - YieldExpression = 181, - SpreadElementExpression = 182, - ClassExpression = 183, - OmittedExpression = 184, - ExpressionWithTypeArguments = 185, - AsExpression = 186, - TemplateSpan = 187, - SemicolonClassElement = 188, - Block = 189, - VariableStatement = 190, - EmptyStatement = 191, - ExpressionStatement = 192, - IfStatement = 193, - DoStatement = 194, - WhileStatement = 195, - ForStatement = 196, - ForInStatement = 197, - ForOfStatement = 198, - ContinueStatement = 199, - BreakStatement = 200, - ReturnStatement = 201, - WithStatement = 202, - SwitchStatement = 203, - LabeledStatement = 204, - ThrowStatement = 205, - TryStatement = 206, - DebuggerStatement = 207, - VariableDeclaration = 208, - VariableDeclarationList = 209, - FunctionDeclaration = 210, - ClassDeclaration = 211, - InterfaceDeclaration = 212, - TypeAliasDeclaration = 213, - EnumDeclaration = 214, - ModuleDeclaration = 215, - ModuleBlock = 216, - CaseBlock = 217, - ImportEqualsDeclaration = 218, - ImportDeclaration = 219, - ImportClause = 220, - NamespaceImport = 221, - NamedImports = 222, - ImportSpecifier = 223, - ExportAssignment = 224, - ExportDeclaration = 225, - NamedExports = 226, - ExportSpecifier = 227, - MissingDeclaration = 228, - ExternalModuleReference = 229, - JsxElement = 230, - JsxSelfClosingElement = 231, - JsxOpeningElement = 232, - JsxText = 233, - JsxClosingElement = 234, - JsxAttribute = 235, - JsxSpreadAttribute = 236, - JsxExpression = 237, - CaseClause = 238, - DefaultClause = 239, - HeritageClause = 240, - CatchClause = 241, - PropertyAssignment = 242, - ShorthandPropertyAssignment = 243, - EnumMember = 244, - SourceFile = 245, - JSDocTypeExpression = 246, - JSDocAllType = 247, - JSDocUnknownType = 248, - JSDocArrayType = 249, - JSDocUnionType = 250, - JSDocTupleType = 251, - JSDocNullableType = 252, - JSDocNonNullableType = 253, - JSDocRecordType = 254, - JSDocRecordMember = 255, - JSDocTypeReference = 256, - JSDocOptionalType = 257, - JSDocFunctionType = 258, - JSDocVariadicType = 259, - JSDocConstructorType = 260, - JSDocThisType = 261, - JSDocComment = 262, - JSDocTag = 263, - JSDocParameterTag = 264, - JSDocReturnTag = 265, - JSDocTypeTag = 266, - JSDocTemplateTag = 267, - SyntaxList = 268, - Count = 269, - FirstAssignment = 54, - LastAssignment = 65, - FirstReservedWord = 67, - LastReservedWord = 102, - FirstKeyword = 67, - LastKeyword = 131, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, - FirstTypeNode = 148, - LastTypeNode = 157, - FirstPunctuation = 14, - LastPunctuation = 65, + ShebangTrivia = 6, + ConflictMarkerTrivia = 7, + NumericLiteral = 8, + StringLiteral = 9, + RegularExpressionLiteral = 10, + NoSubstitutionTemplateLiteral = 11, + TemplateHead = 12, + TemplateMiddle = 13, + TemplateTail = 14, + OpenBraceToken = 15, + CloseBraceToken = 16, + OpenParenToken = 17, + CloseParenToken = 18, + OpenBracketToken = 19, + CloseBracketToken = 20, + DotToken = 21, + DotDotDotToken = 22, + SemicolonToken = 23, + CommaToken = 24, + LessThanToken = 25, + LessThanSlashToken = 26, + GreaterThanToken = 27, + LessThanEqualsToken = 28, + GreaterThanEqualsToken = 29, + EqualsEqualsToken = 30, + ExclamationEqualsToken = 31, + EqualsEqualsEqualsToken = 32, + ExclamationEqualsEqualsToken = 33, + EqualsGreaterThanToken = 34, + PlusToken = 35, + MinusToken = 36, + AsteriskToken = 37, + SlashToken = 38, + PercentToken = 39, + PlusPlusToken = 40, + MinusMinusToken = 41, + LessThanLessThanToken = 42, + GreaterThanGreaterThanToken = 43, + GreaterThanGreaterThanGreaterThanToken = 44, + AmpersandToken = 45, + BarToken = 46, + CaretToken = 47, + ExclamationToken = 48, + TildeToken = 49, + AmpersandAmpersandToken = 50, + BarBarToken = 51, + QuestionToken = 52, + ColonToken = 53, + AtToken = 54, + EqualsToken = 55, + PlusEqualsToken = 56, + MinusEqualsToken = 57, + AsteriskEqualsToken = 58, + SlashEqualsToken = 59, + PercentEqualsToken = 60, + LessThanLessThanEqualsToken = 61, + GreaterThanGreaterThanEqualsToken = 62, + GreaterThanGreaterThanGreaterThanEqualsToken = 63, + AmpersandEqualsToken = 64, + BarEqualsToken = 65, + CaretEqualsToken = 66, + Identifier = 67, + BreakKeyword = 68, + CaseKeyword = 69, + CatchKeyword = 70, + ClassKeyword = 71, + ConstKeyword = 72, + ContinueKeyword = 73, + DebuggerKeyword = 74, + DefaultKeyword = 75, + DeleteKeyword = 76, + DoKeyword = 77, + ElseKeyword = 78, + EnumKeyword = 79, + ExportKeyword = 80, + ExtendsKeyword = 81, + FalseKeyword = 82, + FinallyKeyword = 83, + ForKeyword = 84, + FunctionKeyword = 85, + IfKeyword = 86, + ImportKeyword = 87, + InKeyword = 88, + InstanceOfKeyword = 89, + NewKeyword = 90, + NullKeyword = 91, + ReturnKeyword = 92, + SuperKeyword = 93, + SwitchKeyword = 94, + ThisKeyword = 95, + ThrowKeyword = 96, + TrueKeyword = 97, + TryKeyword = 98, + TypeOfKeyword = 99, + VarKeyword = 100, + VoidKeyword = 101, + WhileKeyword = 102, + WithKeyword = 103, + ImplementsKeyword = 104, + InterfaceKeyword = 105, + LetKeyword = 106, + PackageKeyword = 107, + PrivateKeyword = 108, + ProtectedKeyword = 109, + PublicKeyword = 110, + StaticKeyword = 111, + YieldKeyword = 112, + AbstractKeyword = 113, + AsKeyword = 114, + AnyKeyword = 115, + AsyncKeyword = 116, + AwaitKeyword = 117, + BooleanKeyword = 118, + ConstructorKeyword = 119, + DeclareKeyword = 120, + GetKeyword = 121, + IsKeyword = 122, + ModuleKeyword = 123, + NamespaceKeyword = 124, + RequireKeyword = 125, + NumberKeyword = 126, + SetKeyword = 127, + StringKeyword = 128, + SymbolKeyword = 129, + TypeKeyword = 130, + FromKeyword = 131, + OfKeyword = 132, + QualifiedName = 133, + ComputedPropertyName = 134, + TypeParameter = 135, + Parameter = 136, + Decorator = 137, + PropertySignature = 138, + PropertyDeclaration = 139, + MethodSignature = 140, + MethodDeclaration = 141, + Constructor = 142, + GetAccessor = 143, + SetAccessor = 144, + CallSignature = 145, + ConstructSignature = 146, + IndexSignature = 147, + TypePredicate = 148, + TypeReference = 149, + FunctionType = 150, + ConstructorType = 151, + TypeQuery = 152, + TypeLiteral = 153, + ArrayType = 154, + TupleType = 155, + UnionType = 156, + IntersectionType = 157, + ParenthesizedType = 158, + ObjectBindingPattern = 159, + ArrayBindingPattern = 160, + BindingElement = 161, + ArrayLiteralExpression = 162, + ObjectLiteralExpression = 163, + PropertyAccessExpression = 164, + ElementAccessExpression = 165, + CallExpression = 166, + NewExpression = 167, + TaggedTemplateExpression = 168, + TypeAssertionExpression = 169, + ParenthesizedExpression = 170, + FunctionExpression = 171, + ArrowFunction = 172, + DeleteExpression = 173, + TypeOfExpression = 174, + VoidExpression = 175, + AwaitExpression = 176, + PrefixUnaryExpression = 177, + PostfixUnaryExpression = 178, + BinaryExpression = 179, + ConditionalExpression = 180, + TemplateExpression = 181, + YieldExpression = 182, + SpreadElementExpression = 183, + ClassExpression = 184, + OmittedExpression = 185, + ExpressionWithTypeArguments = 186, + AsExpression = 187, + TemplateSpan = 188, + SemicolonClassElement = 189, + Block = 190, + VariableStatement = 191, + EmptyStatement = 192, + ExpressionStatement = 193, + IfStatement = 194, + DoStatement = 195, + WhileStatement = 196, + ForStatement = 197, + ForInStatement = 198, + ForOfStatement = 199, + ContinueStatement = 200, + BreakStatement = 201, + ReturnStatement = 202, + WithStatement = 203, + SwitchStatement = 204, + LabeledStatement = 205, + ThrowStatement = 206, + TryStatement = 207, + DebuggerStatement = 208, + VariableDeclaration = 209, + VariableDeclarationList = 210, + FunctionDeclaration = 211, + ClassDeclaration = 212, + InterfaceDeclaration = 213, + TypeAliasDeclaration = 214, + EnumDeclaration = 215, + ModuleDeclaration = 216, + ModuleBlock = 217, + CaseBlock = 218, + ImportEqualsDeclaration = 219, + ImportDeclaration = 220, + ImportClause = 221, + NamespaceImport = 222, + NamedImports = 223, + ImportSpecifier = 224, + ExportAssignment = 225, + ExportDeclaration = 226, + NamedExports = 227, + ExportSpecifier = 228, + MissingDeclaration = 229, + ExternalModuleReference = 230, + JsxElement = 231, + JsxSelfClosingElement = 232, + JsxOpeningElement = 233, + JsxText = 234, + JsxClosingElement = 235, + JsxAttribute = 236, + JsxSpreadAttribute = 237, + JsxExpression = 238, + CaseClause = 239, + DefaultClause = 240, + HeritageClause = 241, + CatchClause = 242, + PropertyAssignment = 243, + ShorthandPropertyAssignment = 244, + EnumMember = 245, + SourceFile = 246, + JSDocTypeExpression = 247, + JSDocAllType = 248, + JSDocUnknownType = 249, + JSDocArrayType = 250, + JSDocUnionType = 251, + JSDocTupleType = 252, + JSDocNullableType = 253, + JSDocNonNullableType = 254, + JSDocRecordType = 255, + JSDocRecordMember = 256, + JSDocTypeReference = 257, + JSDocOptionalType = 258, + JSDocFunctionType = 259, + JSDocVariadicType = 260, + JSDocConstructorType = 261, + JSDocThisType = 262, + JSDocComment = 263, + JSDocTag = 264, + JSDocParameterTag = 265, + JSDocReturnTag = 266, + JSDocTypeTag = 267, + JSDocTemplateTag = 268, + SyntaxList = 269, + Count = 270, + FirstAssignment = 55, + LastAssignment = 66, + FirstReservedWord = 68, + LastReservedWord = 103, + FirstKeyword = 68, + LastKeyword = 132, + FirstFutureReservedWord = 104, + LastFutureReservedWord = 112, + FirstTypeNode = 149, + LastTypeNode = 158, + FirstPunctuation = 15, + LastPunctuation = 66, FirstToken = 0, - LastToken = 131, + LastToken = 132, FirstTriviaToken = 2, - LastTriviaToken = 6, - FirstLiteralToken = 7, - LastLiteralToken = 10, - FirstTemplateToken = 10, - LastTemplateToken = 13, - FirstBinaryOperator = 24, - LastBinaryOperator = 65, - FirstNode = 132, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 66, + FirstNode = 133, } const enum NodeFlags { Export = 1, @@ -452,9 +454,9 @@ declare module "typescript" { * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclaration. * Examples: - * FunctionDeclaration - * MethodDeclaration - * AccessorDeclaration + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; @@ -944,7 +946,7 @@ declare module "typescript" { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } - interface ParseConfigHost { + interface ParseConfigHost extends ModuleResolutionHost { readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; } interface WriteFileCallback { @@ -958,6 +960,10 @@ declare module "typescript" { throwIfCancellationRequested(): void; } interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; /** * Get a list of files in the program */ @@ -1026,6 +1032,7 @@ declare module "typescript" { getPropertyOfType(type: Type, propertyName: string): Symbol; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -1049,6 +1056,7 @@ declare module "typescript" { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1193,7 +1201,7 @@ declare module "typescript" { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1213,8 +1221,6 @@ declare module "typescript" { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1310,6 +1316,7 @@ declare module "typescript" { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1362,14 +1369,25 @@ declare module "typescript" { fileNames: string[]; errors: Diagnostic[]; } - interface CompilerHost { + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + failedLookupLocations: string[]; + } + type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule; + interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface TextSpan { start: number; @@ -1443,8 +1461,11 @@ declare module "typescript" { function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare module "typescript" { function getDefaultLibFileName(options: CompilerOptions): string; @@ -1484,13 +1505,14 @@ declare module "typescript" { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare module "typescript" { - /** The version of the TypeScript compiler release */ const version: string; function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare module "typescript" { function parseCommandLine(commandLine: string[]): ParsedCommandLine; @@ -1554,6 +1576,7 @@ declare module "typescript" { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1595,6 +1618,7 @@ declare module "typescript" { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1615,6 +1639,7 @@ declare module "typescript" { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1655,6 +1680,7 @@ declare module "typescript" { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; getSourceFile(fileName: string): SourceFile; @@ -1691,6 +1717,11 @@ declare module "typescript" { span: TextSpan; newText: string; } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } interface RenameLocation { textSpan: TextSpan; fileName: string; @@ -1711,6 +1742,7 @@ declare module "typescript" { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1738,6 +1770,7 @@ declare module "typescript" { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1980,6 +2013,7 @@ declare module "typescript" { * @param compilationSettings The compilation settings used to acquire the file */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; } module ScriptElementKind { const unknown: string; @@ -2066,10 +2100,24 @@ declare module "typescript" { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; diff --git a/lib/typescript.js b/lib/typescript.js index 6035d71fa2b..9507f25db63 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -16,6 +16,7 @@ and limitations under the License. var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -23,324 +24,326 @@ var ts; SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 6] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 7] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 8] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 9] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 10] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 11] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 12] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 13] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 14] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 15] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 16] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 17] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 18] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 19] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 20] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 21] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 10] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -602,21 +605,27 @@ var ts; TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -822,6 +831,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +853,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1003,13 @@ var ts; return array[array.length - 1]; } ts.lastOrUndefined = lastOrUndefined; + /** + * Performs a binary search, finding the index at which 'value' occurs in 'array'. + * If no such index is found, returns the 2's-complement of first index at which + * number[index] exceeds number. + * @param array A sorted array whose first element must be no larger than number + * @param number The value to be searched for in the array. + */ function binarySearch(array, value) { var low = 0; var high = array.length - 1; @@ -1293,7 +1313,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -1470,7 +1490,7 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1699,7 +1719,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1734,7 +1754,7 @@ var ts; function writeFile(fileName, data, writeByteOrderMark) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -1775,7 +1795,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -1799,7 +1819,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1855,9 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + // process and process.nextTick checks if current environment is node-like + // process.browser check excludes webpack and browserify return getNodeSystem(); } else { @@ -2101,6 +2122,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -2140,7 +2162,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -2271,6 +2293,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, 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}'." }, @@ -2350,20 +2374,11 @@ var ts; 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}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_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 'isolatedModules' 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." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, 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." }, @@ -2414,7 +2429,6 @@ var ts; 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'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, @@ -2459,7 +2473,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -2467,123 +2482,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112 /* AbstractKeyword */, - "any": 114 /* AnyKeyword */, - "as": 113 /* AsKeyword */, - "boolean": 117 /* BooleanKeyword */, - "break": 67 /* BreakKeyword */, - "case": 68 /* CaseKeyword */, - "catch": 69 /* CatchKeyword */, - "class": 70 /* ClassKeyword */, - "continue": 72 /* ContinueKeyword */, - "const": 71 /* ConstKeyword */, - "constructor": 118 /* ConstructorKeyword */, - "debugger": 73 /* DebuggerKeyword */, - "declare": 119 /* DeclareKeyword */, - "default": 74 /* DefaultKeyword */, - "delete": 75 /* DeleteKeyword */, - "do": 76 /* DoKeyword */, - "else": 77 /* ElseKeyword */, - "enum": 78 /* EnumKeyword */, - "export": 79 /* ExportKeyword */, - "extends": 80 /* ExtendsKeyword */, - "false": 81 /* FalseKeyword */, - "finally": 82 /* FinallyKeyword */, - "for": 83 /* ForKeyword */, - "from": 130 /* FromKeyword */, - "function": 84 /* FunctionKeyword */, - "get": 120 /* GetKeyword */, - "if": 85 /* IfKeyword */, - "implements": 103 /* ImplementsKeyword */, - "import": 86 /* ImportKeyword */, - "in": 87 /* InKeyword */, - "instanceof": 88 /* InstanceOfKeyword */, - "interface": 104 /* InterfaceKeyword */, - "is": 121 /* IsKeyword */, - "let": 105 /* LetKeyword */, - "module": 122 /* ModuleKeyword */, - "namespace": 123 /* NamespaceKeyword */, - "new": 89 /* NewKeyword */, - "null": 90 /* NullKeyword */, - "number": 125 /* NumberKeyword */, - "package": 106 /* PackageKeyword */, - "private": 107 /* PrivateKeyword */, - "protected": 108 /* ProtectedKeyword */, - "public": 109 /* PublicKeyword */, - "require": 124 /* RequireKeyword */, - "return": 91 /* ReturnKeyword */, - "set": 126 /* SetKeyword */, - "static": 110 /* StaticKeyword */, - "string": 127 /* StringKeyword */, - "super": 92 /* SuperKeyword */, - "switch": 93 /* SwitchKeyword */, - "symbol": 128 /* SymbolKeyword */, - "this": 94 /* ThisKeyword */, - "throw": 95 /* ThrowKeyword */, - "true": 96 /* TrueKeyword */, - "try": 97 /* TryKeyword */, - "type": 129 /* TypeKeyword */, - "typeof": 98 /* TypeOfKeyword */, - "var": 99 /* VarKeyword */, - "void": 100 /* VoidKeyword */, - "while": 101 /* WhileKeyword */, - "with": 102 /* WithKeyword */, - "yield": 111 /* YieldKeyword */, - "async": 115 /* AsyncKeyword */, - "await": 116 /* AwaitKeyword */, - "of": 131 /* OfKeyword */, - "{": 14 /* OpenBraceToken */, - "}": 15 /* CloseBraceToken */, - "(": 16 /* OpenParenToken */, - ")": 17 /* CloseParenToken */, - "[": 18 /* OpenBracketToken */, - "]": 19 /* CloseBracketToken */, - ".": 20 /* DotToken */, - "...": 21 /* DotDotDotToken */, - ";": 22 /* SemicolonToken */, - ",": 23 /* CommaToken */, - "<": 24 /* LessThanToken */, - ">": 26 /* GreaterThanToken */, - "<=": 27 /* LessThanEqualsToken */, - ">=": 28 /* GreaterThanEqualsToken */, - "==": 29 /* EqualsEqualsToken */, - "!=": 30 /* ExclamationEqualsToken */, - "===": 31 /* EqualsEqualsEqualsToken */, - "!==": 32 /* ExclamationEqualsEqualsToken */, - "=>": 33 /* EqualsGreaterThanToken */, - "+": 34 /* PlusToken */, - "-": 35 /* MinusToken */, - "*": 36 /* AsteriskToken */, - "/": 37 /* SlashToken */, - "%": 38 /* PercentToken */, - "++": 39 /* PlusPlusToken */, - "--": 40 /* MinusMinusToken */, - "<<": 41 /* LessThanLessThanToken */, - ">": 42 /* GreaterThanGreaterThanToken */, - ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 44 /* AmpersandToken */, - "|": 45 /* BarToken */, - "^": 46 /* CaretToken */, - "!": 47 /* ExclamationToken */, - "~": 48 /* TildeToken */, - "&&": 49 /* AmpersandAmpersandToken */, - "||": 50 /* BarBarToken */, - "?": 51 /* QuestionToken */, - ":": 52 /* ColonToken */, - "=": 54 /* EqualsToken */, - "+=": 55 /* PlusEqualsToken */, - "-=": 56 /* MinusEqualsToken */, - "*=": 57 /* AsteriskEqualsToken */, - "/=": 58 /* SlashEqualsToken */, - "%=": 59 /* PercentEqualsToken */, - "<<=": 60 /* LessThanLessThanEqualsToken */, - ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 63 /* AmpersandEqualsToken */, - "|=": 64 /* BarEqualsToken */, - "^=": 65 /* CaretEqualsToken */, - "@": 53 /* AtToken */ + "abstract": 113 /* AbstractKeyword */, + "any": 115 /* AnyKeyword */, + "as": 114 /* AsKeyword */, + "boolean": 118 /* BooleanKeyword */, + "break": 68 /* BreakKeyword */, + "case": 69 /* CaseKeyword */, + "catch": 70 /* CatchKeyword */, + "class": 71 /* ClassKeyword */, + "continue": 73 /* ContinueKeyword */, + "const": 72 /* ConstKeyword */, + "constructor": 119 /* ConstructorKeyword */, + "debugger": 74 /* DebuggerKeyword */, + "declare": 120 /* DeclareKeyword */, + "default": 75 /* DefaultKeyword */, + "delete": 76 /* DeleteKeyword */, + "do": 77 /* DoKeyword */, + "else": 78 /* ElseKeyword */, + "enum": 79 /* EnumKeyword */, + "export": 80 /* ExportKeyword */, + "extends": 81 /* ExtendsKeyword */, + "false": 82 /* FalseKeyword */, + "finally": 83 /* FinallyKeyword */, + "for": 84 /* ForKeyword */, + "from": 131 /* FromKeyword */, + "function": 85 /* FunctionKeyword */, + "get": 121 /* GetKeyword */, + "if": 86 /* IfKeyword */, + "implements": 104 /* ImplementsKeyword */, + "import": 87 /* ImportKeyword */, + "in": 88 /* InKeyword */, + "instanceof": 89 /* InstanceOfKeyword */, + "interface": 105 /* InterfaceKeyword */, + "is": 122 /* IsKeyword */, + "let": 106 /* LetKeyword */, + "module": 123 /* ModuleKeyword */, + "namespace": 124 /* NamespaceKeyword */, + "new": 90 /* NewKeyword */, + "null": 91 /* NullKeyword */, + "number": 126 /* NumberKeyword */, + "package": 107 /* PackageKeyword */, + "private": 108 /* PrivateKeyword */, + "protected": 109 /* ProtectedKeyword */, + "public": 110 /* PublicKeyword */, + "require": 125 /* RequireKeyword */, + "return": 92 /* ReturnKeyword */, + "set": 127 /* SetKeyword */, + "static": 111 /* StaticKeyword */, + "string": 128 /* StringKeyword */, + "super": 93 /* SuperKeyword */, + "switch": 94 /* SwitchKeyword */, + "symbol": 129 /* SymbolKeyword */, + "this": 95 /* ThisKeyword */, + "throw": 96 /* ThrowKeyword */, + "true": 97 /* TrueKeyword */, + "try": 98 /* TryKeyword */, + "type": 130 /* TypeKeyword */, + "typeof": 99 /* TypeOfKeyword */, + "var": 100 /* VarKeyword */, + "void": 101 /* VoidKeyword */, + "while": 102 /* WhileKeyword */, + "with": 103 /* WithKeyword */, + "yield": 112 /* YieldKeyword */, + "async": 116 /* AsyncKeyword */, + "await": 117 /* AwaitKeyword */, + "of": 132 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 18 /* CloseParenToken */, + "[": 19 /* OpenBracketToken */, + "]": 20 /* CloseBracketToken */, + ".": 21 /* DotToken */, + "...": 22 /* DotDotDotToken */, + ";": 23 /* SemicolonToken */, + ",": 24 /* CommaToken */, + "<": 25 /* LessThanToken */, + ">": 27 /* GreaterThanToken */, + "<=": 28 /* LessThanEqualsToken */, + ">=": 29 /* GreaterThanEqualsToken */, + "==": 30 /* EqualsEqualsToken */, + "!=": 31 /* ExclamationEqualsToken */, + "===": 32 /* EqualsEqualsEqualsToken */, + "!==": 33 /* ExclamationEqualsEqualsToken */, + "=>": 34 /* EqualsGreaterThanToken */, + "+": 35 /* PlusToken */, + "-": 36 /* MinusToken */, + "*": 37 /* AsteriskToken */, + "/": 38 /* SlashToken */, + "%": 39 /* PercentToken */, + "++": 40 /* PlusPlusToken */, + "--": 41 /* MinusMinusToken */, + "<<": 42 /* LessThanLessThanToken */, + ">": 43 /* GreaterThanGreaterThanToken */, + ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 45 /* AmpersandToken */, + "|": 46 /* BarToken */, + "^": 47 /* CaretToken */, + "!": 48 /* ExclamationToken */, + "~": 49 /* TildeToken */, + "&&": 50 /* AmpersandAmpersandToken */, + "||": 51 /* BarBarToken */, + "?": 52 /* QuestionToken */, + ":": 53 /* ColonToken */, + "=": 55 /* EqualsToken */, + "+=": 56 /* PlusEqualsToken */, + "-=": 57 /* MinusEqualsToken */, + "*=": 58 /* AsteriskEqualsToken */, + "/=": 59 /* SlashEqualsToken */, + "%=": 60 /* PercentEqualsToken */, + "<<=": 61 /* LessThanLessThanEqualsToken */, + ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 64 /* AmpersandEqualsToken */, + "|=": 65 /* BarEqualsToken */, + "^=": 66 /* CaretEqualsToken */, + "@": 54 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2730,14 +2745,21 @@ var ts; } ts.getLineStarts = getLineStarts; /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { // If the actual position was not found, - // the binary search returns the negative value of the next line start + // the binary search returns the 2's-complement of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -2809,6 +2831,9 @@ var ts; case 62 /* greaterThan */: // Starts of conflict marker trivia return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; default: return ch > 127 /* maxAsciiCharacter */; } @@ -2867,6 +2892,12 @@ var ts; continue; } break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2923,13 +2954,28 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -3004,13 +3050,20 @@ var ts; } } function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); + return getCommentRanges(text, pos, /*trailing*/ false); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); + return getCommentRanges(text, pos, /*trailing*/ true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || @@ -3023,7 +3076,6 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } @@ -3050,8 +3102,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, + isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3121,14 +3173,14 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); } /** * Scans as many hexadecimal digits as are available in the text, * returning -1 if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); } function scanHexDigits(minCount, scanAsManyAsPossible) { var digits = 0; @@ -3203,7 +3255,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -3211,14 +3263,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; break; } // Escape character @@ -3280,10 +3332,10 @@ var ts; return scanExtendedUnicodeEscape(); } // '\uDDDD' - return scanHexadecimalEscape(4); + return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: // '\xDD' - return scanHexadecimalEscape(2); + return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". case 13 /* carriageReturn */: @@ -3395,7 +3447,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66 /* Identifier */; + return token = 67 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3430,6 +3482,16 @@ var ts; return token = 1 /* EndOfFileToken */; } var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } switch (ch) { case 10 /* lineFeed */: case 13 /* carriageReturn */: @@ -3465,66 +3527,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 30 /* ExclamationEqualsToken */; + return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 47 /* ExclamationToken */; + return pos++, token = 48 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 8 /* StringLiteral */; + return token = 9 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PercentEqualsToken */; + return pos += 2, token = 60 /* PercentEqualsToken */; } - return pos++, token = 38 /* PercentToken */; + return pos++, token = 39 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 49 /* AmpersandAmpersandToken */; + return pos += 2, token = 50 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AmpersandEqualsToken */; + return pos += 2, token = 64 /* AmpersandEqualsToken */; } - return pos++, token = 44 /* AmpersandToken */; + return pos++, token = 45 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 16 /* OpenParenToken */; + return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 17 /* CloseParenToken */; + return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* AsteriskEqualsToken */; + return pos += 2, token = 58 /* AsteriskEqualsToken */; } - return pos++, token = 36 /* AsteriskToken */; + return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 39 /* PlusPlusToken */; + return pos += 2, token = 40 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* PlusEqualsToken */; + return pos += 2, token = 56 /* PlusEqualsToken */; } - return pos++, token = 34 /* PlusToken */; + return pos++, token = 35 /* PlusToken */; case 44 /* comma */: - return pos++, token = 23 /* CommaToken */; + return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 40 /* MinusMinusToken */; + return pos += 2, token = 41 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* MinusEqualsToken */; + return pos += 2, token = 57 /* MinusEqualsToken */; } - return pos++, token = 35 /* MinusToken */; + return pos++, token = 36 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 21 /* DotDotDotToken */; + return pos += 3, token = 22 /* DotDotDotToken */; } - return pos++, token = 20 /* DotToken */; + return pos++, token = 21 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -3570,9 +3632,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* SlashEqualsToken */; + return pos += 2, token = 59 /* SlashEqualsToken */; } - return pos++, token = 37 /* SlashToken */; + return pos++, token = 38 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3582,32 +3644,32 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(2); + var value = scanBinaryOrOctalDigits(/* base */ 2); if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(8); + var value = scanBinaryOrOctalDigits(/* base */ 8); if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being @@ -3622,11 +3684,11 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 52 /* ColonToken */; + return pos++, token = 53 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 22 /* SemicolonToken */; + return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3634,22 +3696,22 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 41 /* LessThanLessThanToken */; + return pos += 2, token = 42 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 27 /* LessThanEqualsToken */; + return pos += 2, token = 28 /* LessThanEqualsToken */; } if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { - return pos += 2, token = 25 /* LessThanSlashToken */; + return pos += 2, token = 26 /* LessThanSlashToken */; } - return pos++, token = 24 /* LessThanToken */; + return pos++, token = 25 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3657,19 +3719,19 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 29 /* EqualsEqualsToken */; + return pos += 2, token = 30 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 33 /* EqualsGreaterThanToken */; + return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 54 /* EqualsToken */; + return pos++, token = 55 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3677,37 +3739,37 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } - return pos++, token = 26 /* GreaterThanToken */; + return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 51 /* QuestionToken */; + return pos++, token = 52 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 18 /* OpenBracketToken */; + return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 19 /* CloseBracketToken */; + return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* CaretEqualsToken */; + return pos += 2, token = 66 /* CaretEqualsToken */; } - return pos++, token = 46 /* CaretToken */; + return pos++, token = 47 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 14 /* OpenBraceToken */; + return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 50 /* BarBarToken */; + return pos += 2, token = 51 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* BarEqualsToken */; + return pos += 2, token = 65 /* BarEqualsToken */; } - return pos++, token = 45 /* BarToken */; + return pos++, token = 46 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 15 /* CloseBraceToken */; + return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 48 /* TildeToken */; + return pos++, token = 49 /* TildeToken */; case 64 /* at */: - return pos++, token = 53 /* AtToken */; + return pos++, token = 54 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3743,27 +3805,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26 /* GreaterThanToken */) { + if (token === 27 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 42 /* GreaterThanGreaterThanToken */; + return pos++, token = 43 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 28 /* GreaterThanEqualsToken */; + return pos++, token = 29 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { + if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3808,7 +3870,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3878,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -3833,14 +3895,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 25 /* LessThanSlashToken */; + return token = 26 /* LessThanSlashToken */; } pos++; - return token = 24 /* LessThanToken */; + return token = 25 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 14 /* OpenBraceToken */; + return token = 15 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -3849,12 +3911,12 @@ var ts; break; } } - return token = 233 /* JsxText */; + return token = 234 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -3890,10 +3952,10 @@ var ts; return result; } function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookahead:*/ true); } function tryScan(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookahead:*/ false); } function setText(newText, start, length) { text = newText || ""; @@ -3937,16 +3999,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 216 /* ModuleBlock */) { + else if (node.kind === 217 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3965,7 +4027,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4105,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { - return '"' + node.name.text + '"'; + if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4054,22 +4116,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return "__constructor"; - case 149 /* FunctionType */: - case 144 /* CallSignature */: + case 150 /* FunctionType */: + case 145 /* CallSignature */: return "__call"; - case 150 /* ConstructorType */: - case 145 /* ConstructSignature */: + case 151 /* ConstructorType */: + case 146 /* ConstructSignature */: return "__new"; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return "__index"; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return "__export"; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4140,7 +4202,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4221,37 +4283,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 215 /* ModuleDeclaration */: - case 245 /* SourceFile */: - case 213 /* TypeAliasDeclaration */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 216 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 214 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 241 /* CatchClause */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 217 /* CaseBlock */: + case 242 /* CatchClause */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 218 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 189 /* Block */: + case 190 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4288,38 +4350,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: - case 212 /* InterfaceDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: + case 213 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 213 /* TypeAliasDeclaration */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 214 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4349,11 +4411,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 /* SourceFile */ ? node : node.body; - if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { + var body = node.kind === 246 /* SourceFile */ ? node : node.body; + if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { + if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { return true; } } @@ -4372,7 +4434,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8 /* StringLiteral */) { + if (node.name.kind === 9 /* StringLiteral */) { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -4382,14 +4444,21 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { + // if module was already merged with some function, class or non-const enum + // treat is a non-const-enum-only + node.symbol.constEnumOnlyModule = false; } else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -4418,7 +4487,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66 /* Identifier */) { + if (prop.name.kind !== 67 /* Identifier */) { continue; } var identifier = prop.name; @@ -4430,7 +4499,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ + var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4452,10 +4521,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4476,8 +4545,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4512,7 +4581,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 66 /* Identifier */) { + if (inStrictMode && node.expression.kind === 67 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4520,11 +4589,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66 /* Identifier */) { + if (name && name.kind === 67 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4568,7 +4637,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { + if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4612,17 +4681,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245 /* SourceFile */: - case 216 /* ModuleBlock */: + case 246 /* SourceFile */: + case 217 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4645,103 +4714,103 @@ var ts; var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkStrictModeIdentifier(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return checkStrictModeCatchClause(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkStrictModeWithStatement(node); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 135 /* Parameter */: + case 136 /* Parameter */: return bindParameter(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 141 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 142 /* GetAccessor */: + case 142 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 143 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return bindImportClause(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return bindExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return bindExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { @@ -4749,7 +4818,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 66 /* Identifier */) { + else if (node.expression.kind === 67 /* 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 */); } @@ -4774,7 +4843,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -4846,7 +4915,7 @@ 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 === 141 /* Constructor */ && + node.parent.kind === 142 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4912,6 +4981,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); @@ -4936,7 +5036,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245 /* SourceFile */) { + while (node && node.kind !== 246 /* SourceFile */) { node = node.parent; } return node; @@ -5031,7 +5131,7 @@ var ts; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -5048,15 +5148,15 @@ var ts; return current; } switch (current.kind) { - case 245 /* SourceFile */: - case 217 /* CaseBlock */: - case 241 /* CatchClause */: - case 215 /* ModuleDeclaration */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 246 /* SourceFile */: + case 218 /* CaseBlock */: + case 242 /* CatchClause */: + case 216 /* ModuleDeclaration */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return current; - case 189 /* Block */: + case 190 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5069,9 +5169,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 /* VariableDeclaration */ && + declaration.kind === 209 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 241 /* CatchClause */; + declaration.parent.kind === 242 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5101,7 +5201,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -5110,8 +5210,8 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + case 246 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file return ts.createTextSpan(0, 0); @@ -5119,16 +5219,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 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: errorNode = node.name; break; } @@ -5152,11 +5252,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 /* EnumDeclaration */ && isConst(node); + return node.kind === 215 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5171,14 +5271,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 209 /* VariableDeclarationList */) { + if (node && node.kind === 210 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190 /* VariableStatement */) { + if (node && node.kind === 191 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5193,25 +5293,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* 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 === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { - // e.g. (/** blah */ a, /** blah */ b); - // e.g.: ( - // /** blah */ a, - // /** blah */ b); - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { // True if the comment starts with '/**' but not if it is '/**/' return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -5222,40 +5315,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { return true; } switch (node.kind) { - case 114 /* AnyKeyword */: - case 125 /* NumberKeyword */: - case 127 /* StringKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 126 /* NumberKeyword */: + case 128 /* StringKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: return true; - case 100 /* VoidKeyword */: - return node.parent.kind !== 174 /* VoidExpression */; - case 8 /* StringLiteral */: + case 101 /* VoidKeyword */: + return node.parent.kind !== 175 /* VoidExpression */; + case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 135 /* Parameter */; - case 185 /* ExpressionWithTypeArguments */: + return node.parent.kind === 136 /* Parameter */; + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 66 /* Identifier */: + case 67 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 132 /* QualifiedName */: - case 163 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151 /* TypeQuery */) { + if (parent_1.kind === 152 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5264,38 +5357,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 (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return node === parent_1.constraint; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: return node === parent_1.type; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node === parent_1.type; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return node === parent_1.type; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return node === parent_1.type; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5309,23 +5402,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitor(node); - case 217 /* CaseBlock */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: + case 218 /* CaseBlock */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5335,18 +5428,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5354,7 +5447,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5373,14 +5466,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: return true; } } @@ -5388,41 +5481,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); + return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); + return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; + return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5450,7 +5557,7 @@ var ts; return undefined; } switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* 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 @@ -5465,9 +5572,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* 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; @@ -5478,23 +5585,23 @@ var ts; node = node.parent; } break; - case 171 /* ArrowFunction */: + case 172 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 215 /* ModuleDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 214 /* EnumDeclaration */: - case 245 /* SourceFile */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 216 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 215 /* EnumDeclaration */: + case 246 /* SourceFile */: return node; } } @@ -5506,7 +5613,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* 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 @@ -5521,9 +5628,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* 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; @@ -5534,19 +5641,19 @@ var ts; node = node.parent; } break; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node; } } @@ -5555,12 +5662,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: return node.typeName; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return node.expression; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: return node; } } @@ -5568,7 +5675,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5577,44 +5684,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // classes are valid targets return true; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 211 /* ClassDeclaration */; - case 135 /* Parameter */: + return node.parent.kind === 212 /* ClassDeclaration */; + case 136 /* 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 === 211 /* ClassDeclaration */; - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* 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 === 211 /* ClassDeclaration */; + return node.body && node.parent.kind === 212 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: if (node.decorators) { return true; } return false; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5625,10 +5732,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5640,93 +5747,93 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 9 /* RegularExpressionLiteral */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 186 /* AsExpression */: - case 168 /* TypeAssertionExpression */: - case 169 /* ParenthesizedExpression */: - case 170 /* FunctionExpression */: - case 183 /* ClassExpression */: - case 171 /* ArrowFunction */: - case 174 /* VoidExpression */: - case 172 /* DeleteExpression */: - case 173 /* TypeOfExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 180 /* TemplateExpression */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 184 /* OmittedExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 181 /* YieldExpression */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 187 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 170 /* ParenthesizedExpression */: + case 171 /* FunctionExpression */: + case 184 /* ClassExpression */: + case 172 /* ArrowFunction */: + case 175 /* VoidExpression */: + case 173 /* DeleteExpression */: + case 174 /* TypeOfExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 181 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 185 /* OmittedExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 182 /* YieldExpression */: return true; - case 132 /* QualifiedName */: - while (node.parent.kind === 132 /* QualifiedName */) { + case 133 /* QualifiedName */: + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 151 /* TypeQuery */; - case 66 /* Identifier */: - if (node.parent.kind === 151 /* TypeQuery */) { + return node.parent.kind === 152 /* TypeQuery */; + case 67 /* Identifier */: + if (node.parent.kind === 152 /* TypeQuery */) { return true; } // fall through - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 161 /* BindingElement */: return parent_2.initializer === node; - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 205 /* ThrowStatement */: - case 203 /* SwitchStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 206 /* ThrowStatement */: + case 204 /* SwitchStatement */: return parent_2.expression === node; - case 196 /* ForStatement */: + case 197 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forInStatement.expression === node; - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return node === parent_2.expression; - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return node === parent_2.expression; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return node === parent_2.expression; - case 136 /* Decorator */: + case 137 /* Decorator */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5851,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5753,20 +5860,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 229 /* ExternalModuleReference */) { + if (reference.kind === 230 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 225 /* ExportDeclaration */) { + if (node.kind === 226 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5774,15 +5881,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135 /* Parameter */: - return node.questionToken !== undefined; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - return node.questionToken !== undefined; - case 243 /* ShorthandPropertyAssignment */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 136 /* Parameter */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 244 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5790,9 +5895,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 /* JSDocFunctionType */ && + return node.kind === 259 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 260 /* JSDocConstructorType */; + node.parameters[0].type.kind === 261 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5806,26 +5911,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266 /* JSDocTypeTag */); + return getJSDocTag(node, 267 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265 /* JSDocReturnTag */); + return getJSDocTag(node, 266 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267 /* JSDocTemplateTag */); + return getJSDocTag(node, 268 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + if (parameter.name && parameter.name.kind === 67 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264 /* JSDocParameterTag */) { + if (t.kind === 265 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5844,12 +5949,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5858,19 +5963,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); + return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5885,34 +5990,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171 /* ArrowFunction */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 141 /* Constructor */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 227 /* ExportSpecifier */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 220 /* ImportClause */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 212 /* InterfaceDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 215 /* ModuleDeclaration */: - case 221 /* NamespaceImport */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 143 /* SetAccessor */: - case 243 /* ShorthandPropertyAssignment */: - case 213 /* TypeAliasDeclaration */: - case 134 /* TypeParameter */: - case 208 /* VariableDeclaration */: + case 172 /* ArrowFunction */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 142 /* Constructor */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 228 /* ExportSpecifier */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 221 /* ImportClause */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 213 /* InterfaceDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 216 /* ModuleDeclaration */: + case 222 /* NamespaceImport */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 144 /* SetAccessor */: + case 244 /* ShorthandPropertyAssignment */: + case 214 /* TypeAliasDeclaration */: + case 135 /* TypeParameter */: + case 209 /* VariableDeclaration */: return true; } return false; @@ -5920,25 +6025,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 207 /* DebuggerStatement */: - case 194 /* DoStatement */: - case 192 /* ExpressionStatement */: - case 191 /* EmptyStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 204 /* LabeledStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 95 /* ThrowKeyword */: - case 206 /* TryStatement */: - case 190 /* VariableStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 224 /* ExportAssignment */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 208 /* DebuggerStatement */: + case 195 /* DoStatement */: + case 193 /* ExpressionStatement */: + case 192 /* EmptyStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 205 /* LabeledStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 96 /* ThrowKeyword */: + case 207 /* TryStatement */: + case 191 /* VariableStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 225 /* ExportAssignment */: return true; default: return false; @@ -5947,13 +6052,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: return true; default: return false; @@ -5962,11 +6067,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { + if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5981,31 +6086,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 132 /* QualifiedName */) { + while (parent.kind === 133 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 151 /* TypeQuery */; + return parent.kind === 152 /* TypeQuery */; } return false; - case 160 /* BindingElement */: - case 223 /* ImportSpecifier */: + case 161 /* BindingElement */: + case 224 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6021,26 +6126,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 220 /* ImportClause */ && !!node.name || - node.kind === 221 /* NamespaceImport */ || - node.kind === 223 /* ImportSpecifier */ || - node.kind === 227 /* ExportSpecifier */ || - node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; + return node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 221 /* ImportClause */ && !!node.name || + node.kind === 222 /* NamespaceImport */ || + node.kind === 224 /* ImportSpecifier */ || + node.kind === 228 /* ExportSpecifier */ || + node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6109,11 +6214,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; + return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -6129,7 +6234,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 /* ComputedPropertyName */ && + declaration.name.kind === 134 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6139,14 +6244,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 133 /* ComputedPropertyName */) { + if (name.kind === 134 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6164,21 +6269,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 66 /* Identifier */ && node.text === "Symbol"; + return node.kind === 67 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112 /* AbstractKeyword */: - case 115 /* AsyncKeyword */: - case 71 /* ConstKeyword */: - case 119 /* DeclareKeyword */: - case 74 /* DefaultKeyword */: - case 79 /* ExportKeyword */: - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 113 /* AbstractKeyword */: + case 116 /* AsyncKeyword */: + case 72 /* ConstKeyword */: + case 120 /* DeclareKeyword */: + case 75 /* DefaultKeyword */: + case 80 /* ExportKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; } return false; @@ -6186,20 +6291,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135 /* Parameter */; + return root.kind === 136 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160 /* BindingElement */) { + while (node.kind === 161 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; + return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67 /* Identifier */) { + var clone_1 = createSynthesizedNode(67 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -6436,7 +6557,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6448,7 +6569,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); @@ -6465,10 +6586,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 143 /* SetAccessor */) { + else if (accessor.kind === 144 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6477,7 +6598,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) + if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6488,10 +6609,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 /* GetAccessor */ && !getAccessor) { + if (member.kind === 143 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 143 /* SetAccessor */ && !setAccessor) { + if (member.kind === 144 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6593,7 +6714,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -6624,16 +6745,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110 /* StaticKeyword */: return 128 /* Static */; - case 109 /* PublicKeyword */: return 16 /* Public */; - case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 107 /* PrivateKeyword */: return 32 /* Private */; - case 112 /* AbstractKeyword */: return 256 /* Abstract */; - case 79 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: return 2 /* Ambient */; - case 71 /* ConstKeyword */: return 32768 /* Const */; - case 74 /* DefaultKeyword */: return 1024 /* Default */; - case 115 /* AsyncKeyword */: return 512 /* Async */; + case 111 /* StaticKeyword */: return 128 /* Static */; + case 110 /* PublicKeyword */: return 16 /* Public */; + case 109 /* ProtectedKeyword */: return 64 /* Protected */; + case 108 /* PrivateKeyword */: return 32 /* Private */; + case 113 /* AbstractKeyword */: return 256 /* Abstract */; + case 80 /* ExportKeyword */: return 1 /* Export */; + case 120 /* DeclareKeyword */: return 2 /* Ambient */; + case 72 /* ConstKeyword */: return 32768 /* Const */; + case 75 /* DefaultKeyword */: return 1024 /* Default */; + case 116 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6641,29 +6762,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 166 /* NewExpression */: - case 165 /* CallExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 167 /* TaggedTemplateExpression */: - case 161 /* ArrayLiteralExpression */: - case 169 /* ParenthesizedExpression */: - case 162 /* ObjectLiteralExpression */: - case 183 /* ClassExpression */: - case 170 /* FunctionExpression */: - case 66 /* Identifier */: - case 9 /* RegularExpressionLiteral */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 180 /* TemplateExpression */: - case 81 /* FalseKeyword */: - case 90 /* NullKeyword */: - case 94 /* ThisKeyword */: - case 96 /* TrueKeyword */: - case 92 /* SuperKeyword */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 167 /* NewExpression */: + case 166 /* CallExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 168 /* TaggedTemplateExpression */: + case 162 /* ArrayLiteralExpression */: + case 170 /* ParenthesizedExpression */: + case 163 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 171 /* FunctionExpression */: + case 67 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 181 /* TemplateExpression */: + case 82 /* FalseKeyword */: + case 91 /* NullKeyword */: + case 95 /* ThisKeyword */: + case 97 /* TrueKeyword */: + case 93 /* SuperKeyword */: return true; } } @@ -6671,12 +6792,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; + return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 /* ExpressionWithTypeArguments */ && - node.parent.token === 80 /* ExtendsKeyword */ && + return node.kind === 186 /* ExpressionWithTypeArguments */ && + node.parent.token === 81 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6687,10 +6808,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66 /* Identifier */) { + if (node.kind === 67 /* Identifier */) { return true; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6698,10 +6819,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 162 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7004,13 +7136,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134 /* TypeParameter */) { + if (d && d.kind === 135 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { return current; } } @@ -7022,7 +7154,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269 /* Count */); + var nodeConstructors = new Array(270 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7067,20 +7199,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7089,24 +7221,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7117,290 +7249,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 154 /* TupleType */: + case 155 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209 /* VariableDeclarationList */: + case 210 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return visitNode(cbNode, node.label); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 238 /* CaseClause */: + case 239 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239 /* DefaultClause */: + case 240 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136 /* Decorator */: + case 137 /* Decorator */: return visitNode(cbNode, node.expression); - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* 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 212 /* InterfaceDeclaration */: + case 213 /* 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 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229 /* ExternalModuleReference */: + case 230 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235 /* JsxAttribute */: + case 236 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236 /* JsxSpreadAttribute */: + case 237 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 234 /* JsxClosingElement */: + case 235 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 246 /* JSDocTypeExpression */: + case 247 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 250 /* JSDocUnionType */: + case 251 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 251 /* JSDocTupleType */: + case 252 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 249 /* JSDocArrayType */: + case 250 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 253 /* JSDocNonNullableType */: + case 254 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 252 /* JSDocNullableType */: + case 253 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 254 /* JSDocRecordType */: + case 255 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 256 /* JSDocTypeReference */: + case 257 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257 /* JSDocOptionalType */: + case 258 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 258 /* JSDocFunctionType */: + case 259 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259 /* JSDocVariadicType */: + case 260 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 260 /* JSDocConstructorType */: + case 261 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 261 /* JSDocThisType */: + case 262 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordMember */: + case 256 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262 /* JSDocComment */: + case 263 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7408,7 +7540,7 @@ var ts; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); ts.parseTime += new Date().getTime() - start; return result; } @@ -7444,7 +7576,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; @@ -7595,9 +7727,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 190 /* VariableStatement */: - case 210 /* FunctionDeclaration */: - case 135 /* Parameter */: + case 191 /* VariableStatement */: + case 211 /* FunctionDeclaration */: + case 136 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7638,7 +7770,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245 /* SourceFile */, 0); + var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7792,6 +7924,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7823,35 +7958,38 @@ var ts; // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookAhead*/ true); } // Invokes the provided callback. If the callback returns something falsy, then it restores // the parser to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the parser state is not rolled back. The result // of invoking the callback is returned from this function. function tryParse(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookAhead*/ false); } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 111 /* YieldKeyword */ && inYieldContext()) { + if (token === 112 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 102 /* LastReservedWord */; + return token > 103 /* LastReservedWord */; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } // Report specific message if provided with one. Otherwise, report generic fallback message. @@ -7887,22 +8025,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 16 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(22 /* SemicolonToken */); + return parseExpected(23 /* SemicolonToken */); } } function createNode(kind, pos) { @@ -7950,16 +8088,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66 /* Identifier */); + var node = createNode(67 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 66 /* Identifier */) { + if (token !== 67 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -7969,56 +8107,56 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */; + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { - return parseLiteralNode(true); + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token === 18 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); } function parsePropertyName() { - return parsePropertyNameWorker(true); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); } function parseSimplePropertyName() { - return parsePropertyNameWorker(false); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); } function isSimplePropertyName() { - return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword(); } function parseComputedPropertyName() { // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(133 /* ComputedPropertyName */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(134 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71 /* ConstKeyword */) { + if (token === 72 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 78 /* EnumKeyword */; + return nextToken() === 79 /* EnumKeyword */; } - if (token === 79 /* ExportKeyword */) { + if (token === 80 /* ExportKeyword */) { nextToken(); - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -8028,14 +8166,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 /* OpenBracketToken */ - || token === 14 /* OpenBraceToken */ - || token === 36 /* AsteriskToken */ + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; + return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8053,9 +8191,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8063,19 +8201,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -8090,23 +8228,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token === 23 /* CommaToken */ || isStartOfType(); + return token === 24 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); case 13 /* JsxAttributes */: - return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -8119,8 +8257,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14 /* OpenBraceToken */); - if (nextToken() === 15 /* CloseBraceToken */) { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -8129,7 +8267,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; } return true; } @@ -8142,8 +8280,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 /* ImplementsKeyword */ || - token === 80 /* ExtendsKeyword */) { + if (token === 104 /* ImplementsKeyword */ || + token === 81 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8167,43 +8305,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token === 19 /* CloseBracketToken */; + return token === 20 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token === 18 /* CloseParenToken */ || token === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; case 20 /* HeritageClauses */: - return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; case 14 /* JsxChildren */: - return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -8221,7 +8359,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -8231,7 +8369,7 @@ var ts; function isInSomeParsingContext() { for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { return true; } } @@ -8245,7 +8383,7 @@ var ts; var result = []; result.pos = getNodePos(); while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { var element = parseListElement(kind, parseElement); result.push(element); continue; @@ -8385,20 +8523,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: - case 188 /* SemicolonClassElement */: + case 142 /* Constructor */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 189 /* SemicolonClassElement */: return true; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8407,8 +8545,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return true; } } @@ -8417,58 +8555,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 190 /* VariableStatement */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 192 /* ExpressionStatement */: - case 205 /* ThrowStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 191 /* EmptyStatement */: - case 206 /* TryStatement */: - case 204 /* LabeledStatement */: - case 194 /* DoStatement */: - case 207 /* DebuggerStatement */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 191 /* VariableStatement */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 193 /* ExpressionStatement */: + case 206 /* ThrowStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 192 /* EmptyStatement */: + case 207 /* TryStatement */: + case 205 /* LabeledStatement */: + case 195 /* DoStatement */: + case 208 /* DebuggerStatement */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244 /* EnumMember */; + return node.kind === 245 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145 /* ConstructSignature */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 137 /* PropertySignature */: - case 144 /* CallSignature */: + case 146 /* ConstructSignature */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 138 /* PropertySignature */: + case 145 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208 /* VariableDeclaration */) { + if (node.kind !== 209 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8489,7 +8627,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135 /* Parameter */) { + if (node.kind !== 136 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8544,10 +8682,10 @@ var ts; result.pos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -8556,13 +8694,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(23 /* CommaToken */); + parseExpected(24 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === 22 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimeter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8605,8 +8743,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20 /* DotToken */)) { - var node = createNode(132 /* QualifiedName */, entity.pos); + while (parseOptional(21 /* DotToken */)) { + var node = createNode(133 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8639,34 +8777,34 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180 /* TemplateExpression */); + var template = createNode(181 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187 /* TemplateSpan */); + var span = createNode(188 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -8690,7 +8828,7 @@ var ts; // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 7 /* NumericLiteral */ + if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536 /* OctalLiteral */; @@ -8699,31 +8837,31 @@ var ts; } // TYPES function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147 /* TypePredicate */, typeName.pos); + var node_1 = createNode(148 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148 /* TypeReference */, typeName.pos); + var node = createNode(149 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151 /* TypeQuery */); - parseExpected(98 /* TypeOfKeyword */); - node.exprName = parseEntityName(true); + var node = createNode(152 /* TypeQuery */); + parseExpected(99 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134 /* TypeParameter */); + var node = createNode(135 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(80 /* ExtendsKeyword */)) { + if (parseOptional(81 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8745,20 +8883,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(52 /* ColonToken */)) { - return token === 8 /* StringLiteral */ - ? parseLiteralNode(true) + if (parseOptional(53 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8767,10 +8905,10 @@ var ts; } } function parseParameter() { - var node = createNode(135 /* Parameter */); + var node = createNode(136 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -8785,9 +8923,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(51 /* QuestionToken */); + node.questionToken = parseOptionalToken(52 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8802,10 +8940,10 @@ var ts; return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); } function parseParameterInitializer() { - return parseInitializer(true); + return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -8830,7 +8968,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(16 /* OpenParenToken */)) { + if (parseExpected(17 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -8838,7 +8976,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -8853,7 +8991,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -8861,15 +8999,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145 /* ConstructSignature */) { - parseExpected(89 /* NewKeyword */); + if (kind === 146 /* ConstructSignature */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(52 /* ColonToken */, false, false, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18 /* OpenBracketToken */) { + if (token !== 19 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -8892,7 +9030,7 @@ var ts; // [] // nextToken(); - if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { return true; } if (ts.isModifier(token)) { @@ -8911,24 +9049,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 51 /* QuestionToken */) { + if (token !== 52 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146 /* IndexSignature */, fullStart); + var node = createNode(147 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8936,19 +9074,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(139 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(140 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(52 /* ColonToken */, false, false, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137 /* PropertySignature */, fullStart); + var property = createNode(138 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8958,9 +9096,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: return true; default: if (ts.isModifier(token)) { @@ -8980,29 +9118,29 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 /* OpenParenToken */ || - token === 24 /* LessThanToken */ || - token === 51 /* QuestionToken */ || - token === 52 /* ColonToken */ || + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 52 /* QuestionToken */ || + token === 53 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - return parseSignatureMember(144 /* CallSignature */); - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(145 /* CallSignature */); + case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145 /* ConstructSignature */); + return parseSignatureMember(146 /* ConstructSignature */); } // fall through. - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: return parsePropertyOrMethodSignature(); default: // Index declaration as allowed as a type member. But as per the grammar, @@ -9032,18 +9170,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(152 /* TypeLiteral */); + var node = createNode(153 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { members = createMissingList(); @@ -9051,48 +9189,48 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(155 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157 /* ParenthesizedType */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(158 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); node.type = parseType(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150 /* ConstructorType */) { - parseExpected(89 /* NewKeyword */); + if (kind === 151 /* ConstructorType */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 /* DotToken */ ? undefined : node; + return token === 21 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeQuery(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseTypeLiteral(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseTupleType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -9100,19 +9238,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 98 /* TypeOfKeyword */: - case 14 /* OpenBraceToken */: - case 18 /* OpenBracketToken */: - case 24 /* LessThanToken */: - case 89 /* NewKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 99 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 90 /* NewKeyword */: return true; - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -9122,13 +9260,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { - parseExpected(19 /* CloseBracketToken */); - var node = createNode(153 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(154 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9150,28 +9288,28 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); } function isStartOfFunctionType() { - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { return true; } - return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { // ( ) // ( ... return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9180,9 +9318,9 @@ var ts; // ( modifier id return true; } - if (token === 17 /* CloseParenToken */) { + if (token === 18 /* CloseParenToken */) { nextToken(); - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -9197,37 +9335,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149 /* FunctionType */); + return parseFunctionOrConstructorType(150 /* FunctionType */); } - if (token === 89 /* NewKeyword */) { - return parseFunctionOrConstructorType(150 /* ConstructorType */); + if (token === 90 /* NewKeyword */) { + return parseFunctionOrConstructorType(151 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52 /* ColonToken */) ? parseType() : undefined; + return parseOptional(53 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 89 /* NewKeyword */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 66 /* Identifier */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 90 /* NewKeyword */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 67 /* Identifier */: return true; default: return isIdentifier(); @@ -9238,18 +9376,18 @@ var ts; return true; } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 75 /* DeleteKeyword */: - case 98 /* TypeOfKeyword */: - case 100 /* VoidKeyword */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: - case 24 /* LessThanToken */: - case 116 /* AwaitKeyword */: - case 111 /* YieldKeyword */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 76 /* DeleteKeyword */: + case 99 /* TypeOfKeyword */: + case 101 /* VoidKeyword */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: + case 25 /* LessThanToken */: + case 117 /* AwaitKeyword */: + case 112 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9267,10 +9405,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token !== 14 /* OpenBraceToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && - token !== 53 /* AtToken */ && + return token !== 15 /* OpenBraceToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && + token !== 54 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9287,7 +9425,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -9296,7 +9434,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54 /* EqualsToken */) { + if (token !== 55 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9305,7 +9443,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -9313,7 +9451,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9485,11 @@ var ts; // Otherwise, we try to parse out the conditional expression bit. We want to allow any // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. - var expr = parseBinaryExpressionOrHigher(0); + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { + if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9367,7 +9505,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111 /* YieldKeyword */) { + if (token === 112 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9396,15 +9534,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181 /* YieldExpression */); + var node = createNode(182 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + (token === 37 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9415,16 +9553,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171 /* ArrowFunction */, identifier.pos); - var parameter = createNode(135 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172 /* ArrowFunction */, identifier.pos); + var parameter = createNode(136 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9438,7 +9576,7 @@ var ts; // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(true) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { // Didn't appear to actually be a parenthesized arrow function. Just bail out. @@ -9448,8 +9586,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -9459,10 +9597,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9472,28 +9610,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { return 0 /* False */; } } var first = token; var second = nextToken(); - if (first === 16 /* OpenParenToken */) { - if (second === 17 /* CloseParenToken */) { + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 33 /* EqualsGreaterThanToken */: - case 52 /* ColonToken */: - case 14 /* OpenBraceToken */: + case 34 /* EqualsGreaterThanToken */: + case 53 /* ColonToken */: + case 15 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -9505,12 +9643,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 18 /* OpenBracketToken */ || second === 14 /* OpenBraceToken */) { + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 21 /* DotDotDotToken */) { + if (second === 22 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -9523,7 +9661,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 52 /* ColonToken */) { + if (nextToken() === 53 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9531,7 +9669,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 24 /* LessThanToken */); + ts.Debug.assert(first === 25 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -9541,17 +9679,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80 /* ExtendsKeyword */) { + if (third === 81 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 54 /* EqualsToken */: - case 26 /* GreaterThanToken */: + case 55 /* EqualsToken */: + case 27 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 23 /* CommaToken */) { + else if (third === 24 /* CommaToken */) { return true; } return false; @@ -9566,10 +9704,10 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171 /* ArrowFunction */); + var node = createNode(172 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9579,7 +9717,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9592,19 +9730,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 34 /* EqualsGreaterThanToken */ && token !== 15 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, isAsync, false); + if (token === 15 /* OpenBraceToken */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token !== 22 /* SemicolonToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && + if (token !== 23 /* SemicolonToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9621,7 +9759,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, isAsync, true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } return isAsync ? doInAwaitContext(parseAssignmentExpressionOrHigher) @@ -9629,17 +9767,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(51 /* QuestionToken */); + var questionToken = parseOptionalToken(52 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); + node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9648,7 +9786,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; + return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9660,10 +9798,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 /* InKeyword */ && inDisallowInContext()) { + if (token === 88 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9684,46 +9822,46 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87 /* InKeyword */) { + if (inDisallowInContext() && token === 88 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return 1; - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return 2; - case 45 /* BarToken */: + case 46 /* BarToken */: return 3; - case 46 /* CaretToken */: + case 47 /* CaretToken */: return 4; - case 44 /* AmpersandToken */: + case 45 /* AmpersandToken */: return 5; - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: return 6; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 113 /* AsKeyword */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 114 /* AsKeyword */: return 7; - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 9; - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9731,45 +9869,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178 /* BinaryExpression */, left.pos); + var node = createNode(179 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186 /* AsExpression */, left.pos); + var node = createNode(187 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176 /* PrefixUnaryExpression */); + var node = createNode(177 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172 /* DeleteExpression */); + var node = createNode(173 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(173 /* TypeOfExpression */); + var node = createNode(174 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(174 /* VoidExpression */); + var node = createNode(175 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function isAwaitExpression() { - if (token === 116 /* AwaitKeyword */) { + if (token === 117 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9779,7 +9917,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175 /* AwaitExpression */); + var node = createNode(176 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9789,25 +9927,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 75 /* DeleteKeyword */: + case 76 /* DeleteKeyword */: return parseDeleteExpression(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseVoidExpression(); - case 24 /* LessThanToken */: + case 25 /* LessThanToken */: if (sourceFile.languageVariant !== 1 /* JSX */) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } // Fall through default: @@ -9817,8 +9955,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); + if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9857,7 +9995,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 92 /* SuperKeyword */ + var expression = token === 93 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9917,47 +10055,47 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* OpenBracketToken */) { return expression; } // 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(163 /* PropertyAccessExpression */, expression.pos); + var node = createNode(164 /* 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); + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232 /* JsxOpeningElement */) { - var node = createNode(230 /* JsxElement */, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233 /* JsxOpeningElement */) { + var node = createNode(231 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(233 /* JsxText */, scanner.getStartPos()); + var node = createNode(234 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233 /* JsxText */: + case 234 /* JsxText */: return parseJsxText(); - case 14 /* OpenBraceToken */: - return parseJsxExpression(); - case 24 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -9966,7 +10104,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { token = scanner.reScanJsxToken(); - if (token === 25 /* LessThanSlashToken */) { + if (token === 26 /* LessThanSlashToken */) { break; } else if (token === 1 /* EndOfFileToken */) { @@ -9979,19 +10117,29 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24 /* LessThanToken */); + parseExpected(25 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (parseOptional(26 /* GreaterThanToken */)) { - node = createNode(232 /* JsxOpeningElement */, fullStart); + if (token === 27 /* GreaterThanToken */) { + // Closing tag, so scan the immediately-following text with the JSX scanning instead + // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate + // scanning errors + node = createNode(233 /* JsxOpeningElement */, fullStart); + scanJsxText(); } else { - parseExpected(37 /* SlashToken */); - parseExpected(26 /* GreaterThanToken */); - node = createNode(231 /* JsxSelfClosingElement */, fullStart); + parseExpected(38 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(232 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10000,98 +10148,110 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20 /* DotToken */)) { + while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(132 /* QualifiedName */, elementName.pos); + var node = createNode(133 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237 /* JsxExpression */); - parseExpected(14 /* OpenBraceToken */); - if (token !== 15 /* CloseBraceToken */) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); } - parseExpected(15 /* CloseBraceToken */); + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235 /* JsxAttribute */); + var node = createNode(236 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { switch (token) { - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236 /* JsxSpreadAttribute */); - parseExpected(14 /* OpenBraceToken */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(237 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234 /* JsxClosingElement */); - parseExpected(25 /* LessThanSlashToken */); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); - parseExpected(26 /* GreaterThanToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168 /* TypeAssertionExpression */); - parseExpected(24 /* LessThanToken */); + var node = createNode(169 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); node.type = parseType(); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20 /* DotToken */); + var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } // 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(164 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { + var indexedAccess = createNode(165 /* 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. - if (token !== 19 /* CloseBracketToken */) { + if (token !== 20 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -10103,7 +10263,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -10112,15 +10272,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(165 /* CallExpression */, expression.pos); + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(165 /* CallExpression */, expression.pos); + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10130,17 +10290,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24 /* LessThanToken */)) { + if (!parseOptional(25 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(26 /* GreaterThanToken */)) { + if (!parseExpected(27 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -10152,32 +10312,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16 /* OpenParenToken */: // foo( + case 17 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 20 /* DotToken */: // foo. - case 17 /* CloseParenToken */: // foo) - case 19 /* CloseBracketToken */: // foo] - case 52 /* ColonToken */: // foo: - case 22 /* SemicolonToken */: // foo; - case 51 /* QuestionToken */: // foo? - case 29 /* EqualsEqualsToken */: // foo == - case 31 /* EqualsEqualsEqualsToken */: // foo === - case 30 /* ExclamationEqualsToken */: // foo != - case 32 /* ExclamationEqualsEqualsToken */: // foo !== - case 49 /* AmpersandAmpersandToken */: // foo && - case 50 /* BarBarToken */: // foo || - case 46 /* CaretToken */: // foo ^ - case 44 /* AmpersandToken */: // foo & - case 45 /* BarToken */: // foo | - case 15 /* CloseBraceToken */: // foo } + case 21 /* DotToken */: // foo. + case 18 /* CloseParenToken */: // foo) + case 20 /* CloseBracketToken */: // foo] + case 53 /* ColonToken */: // foo: + case 23 /* SemicolonToken */: // foo; + case 52 /* QuestionToken */: // foo? + case 30 /* EqualsEqualsToken */: // foo == + case 32 /* EqualsEqualsEqualsToken */: // foo === + case 31 /* ExclamationEqualsToken */: // foo != + case 33 /* ExclamationEqualsEqualsToken */: // foo !== + case 50 /* AmpersandAmpersandToken */: // foo && + case 51 /* BarBarToken */: // foo || + case 47 /* CaretToken */: // foo ^ + case 45 /* AmpersandToken */: // foo & + case 46 /* BarToken */: // foo | + case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 23 /* CommaToken */: // foo, - case 14 /* OpenBraceToken */: // foo { + case 24 /* CommaToken */: // foo, + case 15 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -10188,23 +10348,23 @@ var ts; } function parsePrimaryExpression() { switch (token) { - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return parseTokenNode(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedExpression(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10212,59 +10372,59 @@ var ts; break; } return parseFunctionExpression(); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassExpression(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionExpression(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseNewExpression(); - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 11 /* TemplateHead */: + case 12 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169 /* ParenthesizedExpression */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(170 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182 /* SpreadElementExpression */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(183 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161 /* ArrayLiteralExpression */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(162 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120 /* GetKeyword */)) { - return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(121 /* GetKeyword */)) { + return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(126 /* SetKeyword */)) { - return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(127 /* SetKeyword */)) { + return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10276,39 +10436,39 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // 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(243 /* ShorthandPropertyAssignment */, fullStart); + if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162 /* ObjectLiteralExpression */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(163 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); - parseExpected(15 /* CloseBraceToken */); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -10321,10 +10481,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170 /* FunctionExpression */); + var node = createNode(171 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); node.name = @@ -10332,8 +10492,8 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -10343,21 +10503,21 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166 /* NewExpression */); - parseExpected(89 /* NewKeyword */); + var node = createNode(167 /* NewExpression */); + parseExpected(90 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16 /* OpenParenToken */) { + if (node.typeArguments || token === 17 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189 /* Block */); - if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -10384,84 +10544,84 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191 /* EmptyStatement */); - parseExpected(22 /* SemicolonToken */); + var node = createNode(192 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(193 /* IfStatement */); - parseExpected(85 /* IfKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(194 /* IfStatement */); + parseExpected(86 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194 /* DoStatement */); - parseExpected(76 /* DoKeyword */); + var node = createNode(195 /* DoStatement */); + parseExpected(77 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(22 /* SemicolonToken */); + parseOptional(23 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195 /* WhileStatement */); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(196 /* WhileStatement */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83 /* ForKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(84 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); var initializer = undefined; - if (token !== 22 /* SemicolonToken */) { - if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(true); + if (token !== 23 /* SemicolonToken */) { + if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { initializer = disallowInAnd(parseExpression); } } var forOrForInOrForOfStatement; - if (parseOptional(87 /* InKeyword */)) { - var forInStatement = createNode(197 /* ForInStatement */, pos); + if (parseOptional(88 /* InKeyword */)) { + var forInStatement = createNode(198 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131 /* OfKeyword */)) { - var forOfStatement = createNode(198 /* ForOfStatement */, pos); + else if (parseOptional(132 /* OfKeyword */)) { + var forOfStatement = createNode(199 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196 /* ForStatement */, pos); + var forStatement = createNode(197 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(22 /* SemicolonToken */); - if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22 /* SemicolonToken */); - if (token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -10469,7 +10629,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); + parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10477,8 +10637,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201 /* ReturnStatement */); - parseExpected(91 /* ReturnKeyword */); + var node = createNode(202 /* ReturnStatement */); + parseExpected(92 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10486,42 +10646,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202 /* WithStatement */); - parseExpected(102 /* WithKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(203 /* WithStatement */); + parseExpected(103 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238 /* CaseClause */); - parseExpected(68 /* CaseKeyword */); + var node = createNode(239 /* CaseClause */); + parseExpected(69 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239 /* DefaultClause */); - parseExpected(74 /* DefaultKeyword */); - parseExpected(52 /* ColonToken */); + var node = createNode(240 /* DefaultClause */); + parseExpected(75 /* DefaultKeyword */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203 /* SwitchStatement */); - parseExpected(93 /* SwitchKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(204 /* SwitchStatement */); + parseExpected(94 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); - parseExpected(14 /* OpenBraceToken */); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -10533,39 +10693,39 @@ 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(205 /* ThrowStatement */); - parseExpected(95 /* ThrowKeyword */); + var node = createNode(206 /* ThrowStatement */); + parseExpected(96 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(206 /* TryStatement */); - parseExpected(97 /* TryKeyword */); - node.tryBlock = parseBlock(false); - node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; + var node = createNode(207 /* TryStatement */); + parseExpected(98 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 82 /* FinallyKeyword */) { - parseExpected(82 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false); + if (!node.catchClause || token === 83 /* FinallyKeyword */) { + parseExpected(83 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241 /* CatchClause */); - parseExpected(69 /* CatchKeyword */); - if (parseExpected(16 /* OpenParenToken */)) { + var result = createNode(242 /* CatchClause */); + parseExpected(70 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false); + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207 /* DebuggerStatement */); - parseExpected(73 /* DebuggerKeyword */); + var node = createNode(208 /* DebuggerStatement */); + parseExpected(74 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10575,21 +10735,21 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { - var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); + if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { + var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66 /* Identifier */; + return token >= 67 /* Identifier */; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -10597,21 +10757,21 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10634,36 +10794,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 79 /* ExportKeyword */: + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword(); + case 80 /* ExportKeyword */: nextToken(); - if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { + if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { return true; } continue; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: - case 112 /* AbstractKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: + case 113 /* AbstractKeyword */: nextToken(); continue; default: @@ -10676,47 +10836,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53 /* AtToken */: - case 22 /* SemicolonToken */: - case 14 /* OpenBraceToken */: - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 85 /* IfKeyword */: - case 76 /* DoKeyword */: - case 101 /* WhileKeyword */: - case 83 /* ForKeyword */: - case 72 /* ContinueKeyword */: - case 67 /* BreakKeyword */: - case 91 /* ReturnKeyword */: - case 102 /* WithKeyword */: - case 93 /* SwitchKeyword */: - case 95 /* ThrowKeyword */: - case 97 /* TryKeyword */: - case 73 /* DebuggerKeyword */: + case 54 /* AtToken */: + case 23 /* SemicolonToken */: + case 15 /* OpenBraceToken */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 86 /* IfKeyword */: + case 77 /* DoKeyword */: + case 102 /* WhileKeyword */: + case 84 /* ForKeyword */: + case 73 /* ContinueKeyword */: + case 68 /* BreakKeyword */: + case 92 /* ReturnKeyword */: + case 103 /* WithKeyword */: + case 94 /* SwitchKeyword */: + case 96 /* ThrowKeyword */: + case 98 /* TryKeyword */: + case 74 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return true; - case 71 /* ConstKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: + case 72 /* ConstKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: - case 104 /* InterfaceKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 129 /* TypeKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: + case 105 /* InterfaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 130 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10726,7 +10886,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -10735,65 +10895,65 @@ var ts; } function parseStatement() { switch (token) { - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: return parseEmptyStatement(); - case 14 /* OpenBraceToken */: - return parseBlock(false); - case 99 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105 /* LetKeyword */: + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 100 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 106 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 84 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 85 /* IfKeyword */: + case 85 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 71 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 86 /* IfKeyword */: return parseIfStatement(); - case 76 /* DoKeyword */: + case 77 /* DoKeyword */: return parseDoStatement(); - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return parseWhileStatement(); - case 83 /* ForKeyword */: + case 84 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 72 /* ContinueKeyword */: - return parseBreakOrContinueStatement(199 /* ContinueStatement */); - case 67 /* BreakKeyword */: - return parseBreakOrContinueStatement(200 /* BreakStatement */); - case 91 /* ReturnKeyword */: + case 73 /* ContinueKeyword */: + return parseBreakOrContinueStatement(200 /* ContinueStatement */); + case 68 /* BreakKeyword */: + return parseBreakOrContinueStatement(201 /* BreakStatement */); + case 92 /* ReturnKeyword */: return parseReturnStatement(); - case 102 /* WithKeyword */: + case 103 /* WithKeyword */: return parseWithStatement(); - case 93 /* SwitchKeyword */: + case 94 /* SwitchKeyword */: return parseSwitchStatement(); - case 95 /* ThrowKeyword */: + case 96 /* ThrowKeyword */: return parseThrowStatement(); - case 97 /* TryKeyword */: + case 98 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return parseTryStatement(); - case 73 /* DebuggerKeyword */: + case 74 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 53 /* AtToken */: + case 54 /* AtToken */: return parseDeclaration(); - case 115 /* AsyncKeyword */: - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 119 /* DeclareKeyword */: - case 71 /* ConstKeyword */: - case 78 /* EnumKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 109 /* PublicKeyword */: - case 112 /* AbstractKeyword */: - case 110 /* StaticKeyword */: + case 116 /* AsyncKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 120 /* DeclareKeyword */: + case 72 /* ConstKeyword */: + case 79 /* EnumKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 113 /* AbstractKeyword */: + case 111 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10806,35 +10966,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104 /* InterfaceKeyword */: + case 105 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129 /* TypeKeyword */: + case 130 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78 /* EnumKeyword */: + case 79 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: nextToken(); - return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? + return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10844,86 +11004,86 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { - if (token === 23 /* CommaToken */) { - return createNode(184 /* OmittedExpression */); + if (token === 24 /* CommaToken */) { + return createNode(185 /* OmittedExpression */); } - var node = createNode(160 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + var node = createNode(161 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160 /* BindingElement */); + var node = createNode(161 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52 /* ColonToken */) { + if (tokenIsIdentifier && token !== 53 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158 /* ObjectBindingPattern */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(159 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159 /* ArrayBindingPattern */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(160 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208 /* VariableDeclaration */); + var node = createNode(209 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); + node.initializer = parseInitializer(/*inParameter*/ false); } return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209 /* VariableDeclarationList */); + var node = createNode(210 /* VariableDeclarationList */); switch (token) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -10939,7 +11099,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 === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10951,40 +11111,40 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190 /* VariableStatement */, fullStart); + var node = createNode(191 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210 /* FunctionDeclaration */, fullStart); + var node = createNode(211 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141 /* Constructor */, pos); + var node = createNode(142 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118 /* ConstructorKeyword */); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + parseExpected(119 /* ConstructorKeyword */); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140 /* MethodDeclaration */, fullStart); + var method = createNode(141 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10992,12 +11152,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138 /* PropertyDeclaration */, fullStart); + var property = createNode(139 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11019,12 +11179,12 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -11032,23 +11192,23 @@ var ts; } } function parseNonParameterInitializer() { - return parseInitializer(false); + return parseInitializer(/*inParameter*/ false); } function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; default: return false; @@ -11056,7 +11216,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53 /* AtToken */) { + if (token === 54 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11073,7 +11233,7 @@ var ts; } nextToken(); } - if (token === 36 /* AsteriskToken */) { + if (token === 37 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -11083,23 +11243,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return true; } // 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 === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token) { - case 16 /* OpenParenToken */: // Method declaration - case 24 /* LessThanToken */: // Generic Method declaration - case 52 /* ColonToken */: // Type Annotation for declaration - case 54 /* EqualsToken */: // Initializer for declaration - case 51 /* QuestionToken */: + case 17 /* OpenParenToken */: // Method declaration + case 25 /* LessThanToken */: // Generic Method declaration + case 53 /* ColonToken */: // Type Annotation for declaration + case 55 /* EqualsToken */: // Initializer for declaration + case 52 /* QuestionToken */: return true; default: // Covers @@ -11116,14 +11276,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53 /* AtToken */)) { + if (!parseOptional(54 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136 /* Decorator */, decoratorStart); + var decorator = createNode(137 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11157,7 +11317,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11171,8 +11331,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22 /* SemicolonToken */) { - var result = createNode(188 /* SemicolonClassElement */); + if (token === 23 /* SemicolonToken */) { + var result = createNode(189 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11183,7 +11343,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11192,16 +11352,16 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */ || - token === 36 /* AsteriskToken */ || - token === 18 /* OpenBracketToken */) { + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); + var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -11210,24 +11370,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 183 /* ClassExpression */); + /*modifiers*/ undefined, 184 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70 /* ClassKeyword */); + parseExpected(71 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11246,8 +11406,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { - var node = createNode(240 /* HeritageClause */); + if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { + var node = createNode(241 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11256,38 +11416,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185 /* ExpressionWithTypeArguments */); + var node = createNode(186 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212 /* InterfaceDeclaration */, fullStart); + var node = createNode(213 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104 /* InterfaceKeyword */); + parseExpected(105 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* TypeAliasDeclaration */, fullStart); + var node = createNode(214 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129 /* TypeKeyword */); + parseExpected(130 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11297,20 +11457,20 @@ 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(244 /* EnumMember */, scanner.getStartPos()); + var node = createNode(245 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* EnumDeclaration */, fullStart); + var node = createNode(215 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78 /* EnumKeyword */); + parseExpected(79 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11318,10 +11478,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(14 /* OpenBraceToken */)) { + var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -11329,84 +11489,84 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + node.name = parseLiteralNode(/*internName*/ true); node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123 /* NamespaceKeyword */)) { + if (parseOptional(124 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(122 /* ModuleKeyword */); - if (token === 8 /* StringLiteral */) { + parseExpected(123 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 /* RequireKeyword */ && + return token === 125 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16 /* OpenParenToken */; + return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 37 /* SlashToken */; + return nextToken() === 38 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 /* CommaToken */ || - token === 130 /* FromKeyword */; + return token === 24 /* CommaToken */ || + token === 131 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86 /* ImportKeyword */); + parseExpected(87 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */) { + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130 /* FromKeyword */); + parseExpected(131 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11419,7 +11579,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220 /* ImportClause */, fullStart); + var importClause = createNode(221 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11428,22 +11588,22 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); + parseOptional(24 /* CommaToken */)) { + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); } return finishNode(importClause); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(229 /* ExternalModuleReference */); - parseExpected(124 /* RequireKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(230 /* ExternalModuleReference */); + parseExpected(125 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -11453,7 +11613,7 @@ var ts; var result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 8 /* StringLiteral */) { + if (result.kind === 9 /* StringLiteral */) { internIdentifier(result.text); } return result; @@ -11461,9 +11621,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(221 /* NamespaceImport */); - parseExpected(36 /* AsteriskToken */); - parseExpected(113 /* AsKeyword */); + var namespaceImport = createNode(222 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(114 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11476,14 +11636,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227 /* ExportSpecifier */); + return parseImportOrExportSpecifier(228 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223 /* ImportSpecifier */); + return parseImportOrExportSpecifier(224 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11497,9 +11657,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(113 /* AsKeyword */); + parseExpected(114 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11508,27 +11668,27 @@ var ts; else { node.name = identifierName; } - if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 224 /* 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(225 /* ExportDeclaration */, fullStart); + var node = createNode(226 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36 /* AsteriskToken */)) { - parseExpected(130 /* FromKeyword */); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(130 /* FromKeyword */); + if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11536,21 +11696,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224 /* ExportAssignment */, fullStart); + var node = createNode(225 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(74 /* DefaultKeyword */); + parseExpected(75 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11609,10 +11769,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ - || node.kind === 219 /* ImportDeclaration */ - || node.kind === 224 /* ExportAssignment */ - || node.kind === 225 /* ExportDeclaration */ + || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ + || node.kind === 220 /* ImportDeclaration */ + || node.kind === 225 /* ExportAssignment */ + || node.kind === 226 /* ExportDeclaration */ ? node : undefined; }); @@ -11657,23 +11817,23 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36 /* AsteriskToken */: - case 51 /* QuestionToken */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 47 /* ExclamationToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 21 /* DotDotDotToken */: - case 89 /* NewKeyword */: - case 94 /* ThisKeyword */: + case 37 /* AsteriskToken */: + case 52 /* QuestionToken */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 48 /* ExclamationToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 22 /* DotDotDotToken */: + case 90 /* NewKeyword */: + case 95 /* ThisKeyword */: return true; } return isIdentifierOrKeyword(); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11687,23 +11847,23 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(246 /* JSDocTypeExpression */); - parseExpected(14 /* OpenBraceToken */); + var result = createNode(247 /* JSDocTypeExpression */); + parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45 /* BarToken */) { - var unionType = createNode(250 /* JSDocUnionType */, type.pos); + if (token === 46 /* BarToken */) { + var unionType = createNode(251 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54 /* EqualsToken */) { - var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); + if (token === 55 /* EqualsToken */) { + var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11713,21 +11873,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(249 /* JSDocArrayType */, type.pos); + if (token === 19 /* OpenBracketToken */) { + var arrayType = createNode(250 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 51 /* QuestionToken */) { - var nullableType = createNode(252 /* JSDocNullableType */, type.pos); + else if (token === 52 /* QuestionToken */) { + var nullableType = createNode(253 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47 /* ExclamationToken */) { - var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); + else if (token === 48 /* ExclamationToken */) { + var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11740,85 +11900,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36 /* AsteriskToken */: + case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 51 /* QuestionToken */: + case 52 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseJSDocUnionType(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 21 /* DotDotDotToken */: + case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseJSDocConstructorType(); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return parseJSDocThisType(); - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261 /* JSDocThisType */); + var result = createNode(262 /* JSDocThisType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260 /* JSDocConstructorType */); + var result = createNode(261 /* JSDocConstructorType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259 /* JSDocVariadicType */); + var result = createNode(260 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258 /* JSDocFunctionType */); + var result = createNode(259 /* JSDocFunctionType */); nextToken(); - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17 /* CloseParenToken */); - if (token === 52 /* ColonToken */) { + parseExpected(18 /* CloseParenToken */); + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135 /* Parameter */); + var parameter = createNode(136 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257 /* JSDocOptionalType */, type.pos); + var result = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256 /* JSDocTypeReference */); + var result = createNode(257 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(20 /* DotToken */)) { - if (token === 24 /* LessThanToken */) { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -11834,7 +11994,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11845,40 +12005,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132 /* QualifiedName */, left.pos); + var result = createNode(133 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254 /* JSDocRecordType */); + var result = createNode(255 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255 /* JSDocRecordMember */); + var result = createNode(256 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 52 /* ColonToken */) { + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253 /* JSDocNonNullableType */); + var result = createNode(254 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251 /* JSDocTupleType */); + var result = createNode(252 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -11888,10 +12048,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250 /* JSDocUnionType */); + var result = createNode(251 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -11899,14 +12059,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45 /* BarToken */)) { + while (parseOptional(46 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247 /* JSDocAllType */); + var result = createNode(248 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11923,24 +12083,24 @@ var ts; // Foo // Foo(?= // (?| - if (token === 23 /* CommaToken */ || - token === 15 /* CloseBraceToken */ || - token === 17 /* CloseParenToken */ || - token === 26 /* GreaterThanToken */ || - token === 54 /* EqualsToken */ || - token === 45 /* BarToken */) { - var result = createNode(248 /* JSDocUnknownType */, pos); + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 55 /* EqualsToken */ || + token === 46 /* BarToken */) { + var result = createNode(249 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(252 /* JSDocNullableType */, pos); + var result = createNode(253 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; @@ -12021,7 +12181,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262 /* JSDocComment */, start); + var result = createNode(263 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12032,7 +12192,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(53 /* AtToken */, pos - 1); + var atToken = createNode(54 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12058,7 +12218,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263 /* JSDocTag */, atToken.pos); + var result = createNode(264 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12110,7 +12270,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264 /* JSDocParameterTag */, atToken.pos); + var result = createNode(265 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12120,27 +12280,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(265 /* JSDocReturnTag */, atToken.pos); + var result = createNode(266 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocTypeTag */, atToken.pos); + var result = createNode(267 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12153,7 +12313,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12164,7 +12324,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12185,7 +12345,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66 /* Identifier */, startPos); + var result = createNode(67 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12205,7 +12365,7 @@ var ts; if (sourceFile.statements.length === 0) { // If we don't have any statements in the current source file, then there's no real // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); } // Make sure we're not trying to incrementally update a source file more than once. Once // we do an update the original source file is considered unusbale from that point onwards. @@ -12261,7 +12421,7 @@ var ts; // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12274,7 +12434,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12466,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: - case 66 /* Identifier */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 67 /* Identifier */: return true; } return false; @@ -12400,7 +12560,7 @@ var ts; if (child.pos > changeRangeOldEnd) { // Node is entirely past the change range. We need to move both its pos and // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12424,7 +12584,7 @@ var ts; if (array.pos > changeRangeOldEnd) { // Array is entirely after the change range. We need to move it, and move any of // its children. - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12717,17 +12877,20 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -12744,7 +12907,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12752,16 +12916,19 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -12806,6 +12973,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +12995,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13008,15 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -12984,10 +13161,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245 /* SourceFile */); + return ts.getAncestor(node, 246 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13013,7 +13190,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -13044,13 +13221,13 @@ var ts; } } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 /* SourceFile */ || - (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 246 /* SourceFile */ || + (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13064,7 +13241,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13078,13 +13255,13 @@ var ts; break loop; } break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* 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 @@ -13101,9 +13278,9 @@ var ts; } } break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* 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 @@ -13114,7 +13291,7 @@ var ts; } break loop; } - if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13130,9 +13307,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* 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); @@ -13140,19 +13317,19 @@ var ts; } } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13165,7 +13342,7 @@ var ts; } } break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13174,7 +13351,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 === 135 /* Parameter */) { + if (location.parent && location.parent.kind === 136 /* Parameter */) { location = location.parent; } // @@ -13209,7 +13386,18 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2 /* BlockScopedVariable */) { + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -13230,16 +13418,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, 208 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 197 /* 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 === 198 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -13266,10 +13454,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 219 /* ImportDeclaration */) { + while (node && node.kind !== 220 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13279,7 +13467,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13386,17 +13574,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return getTargetOfImportClause(node); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 223 /* ImportSpecifier */: + case 224 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13441,11 +13629,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224 /* ExportAssignment */) { + if (node.kind === 225 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 227 /* ExportSpecifier */) { + else if (node.kind === 228 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13458,7 +13646,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13467,17 +13655,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { + if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* 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 === 218 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13490,16 +13678,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { - var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { + var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13524,7 +13712,7 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -13532,29 +13720,18 @@ var ts; // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -13662,7 +13839,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13732,17 +13909,17 @@ var ts; } } switch (location_1.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13783,7 +13960,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13820,7 +13997,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13836,7 +14013,7 @@ var ts; var meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -13893,8 +14070,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13930,12 +14107,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 151 /* TypeQuery */) { + if (entityName.parent.kind === 152 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || - entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || + entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13945,7 +14122,7 @@ var ts; meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, @@ -13990,17 +14167,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157 /* ParenthesizedType */) { + while (node.kind === 158 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 214 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -14009,10 +14184,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return "(Anonymous class)"; - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14042,7 +14217,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14273,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 4194431 /* Intrinsic */) { + if (type.flags & 16777343 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -14126,23 +14301,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23 /* CommaToken */) { + if (delimiter !== 24 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -14152,22 +14327,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); } if (pos < end) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); writeType(typeArguments[pos++], 0 /* None */); while (pos < end) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 18 /* OpenBracketToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -14188,7 +14363,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } } } @@ -14196,17 +14371,17 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 23 /* CommaToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -14228,7 +14403,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14427,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; + return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14262,7 +14437,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98 /* TypeOfKeyword */); + writeKeyword(writer, 99 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14280,76 +14455,76 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14 /* OpenBraceToken */); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 127 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 128 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { // [x: number]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 125 /* NumberKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 126 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -14361,27 +14536,27 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -14395,7 +14570,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80 /* ExtendsKeyword */); + writeKeyword(writer, 81 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14403,67 +14578,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 33 /* EqualsGreaterThanToken */); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121 /* IsKeyword */); + writeKeyword(writer, 122 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14485,15 +14660,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -14502,12 +14674,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215 /* ModuleDeclaration */) { - if (node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 216 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 245 /* SourceFile */) { + else if (node.kind === 246 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -14556,70 +14728,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160 /* BindingElement */: + case 161 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 208 /* VariableDeclaration */: + case 209 /* 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 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 210 /* FunctionDeclaration */: - case 214 /* EnumDeclaration */: - case 218 /* ImportEqualsDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 215 /* EnumDeclaration */: + case 219 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 140 /* 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 141 /* Constructor */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: - case 135 /* Parameter */: - case 216 /* ModuleBlock */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: - case 148 /* TypeReference */: - case 153 /* ArrayType */: - case 154 /* TupleType */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 157 /* ParenthesizedType */: + case 142 /* Constructor */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: + case 136 /* Parameter */: + case 217 /* ModuleBlock */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: + case 149 /* TypeReference */: + case 154 /* ArrayType */: + case 155 /* TupleType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 158 /* 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 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: return false; // Type parameters are always visible - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: // Source file is always visible - case 245 /* SourceFile */: + case 246 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14635,11 +14807,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } var result = []; if (exportSymbol) { @@ -14663,40 +14838,71 @@ 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); + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } // 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(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14732,7 +14938,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -14749,11 +14955,8 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -14779,10 +14982,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 === 197 /* ForInStatement */) { + if (declaration.parent.parent.kind === 198 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 199 /* 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, @@ -14796,11 +14999,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* 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 === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); + if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14816,9 +15019,13 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } // No type specified and nothing can be inferred return undefined; } @@ -14851,7 +15058,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -14874,7 +15081,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 === 158 /* ObjectBindingPattern */ + return pattern.kind === 159 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -14896,19 +15103,14 @@ 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 !== 242 /* 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 - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14923,18 +15125,18 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241 /* CatchClause */) { + if (declaration.parent.kind === 242 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 224 /* ExportAssignment */) { + if (declaration.kind === 225 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); if (!popTypeResolution()) { if (symbol.valueDeclaration.type) { // Variable has type annotation that circularly references the variable itself @@ -14955,7 +15157,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -14968,11 +15170,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15001,7 +15203,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* 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)); } } @@ -15101,9 +15303,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || - node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { + if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || + node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15113,7 +15315,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15122,8 +15324,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || - node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || + node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15166,7 +15368,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -15234,7 +15436,7 @@ var ts; return; } if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } type.resolvedBaseTypes = [baseType]; @@ -15243,7 +15445,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15253,7 +15455,7 @@ var ts; type.resolvedBaseTypes.push(baseType); } else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); } } else { @@ -15289,10 +15491,10 @@ var ts; if (!links.declaredType) { // 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)) { + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15325,7 +15527,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15492,43 +15694,70 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; } - // If the lists of call or construct signatures in the given types are all identical except for return types, - // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the - // return types of the corresponding signatures in each resulting signature. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; } - } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } } + return [signature]; } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } } return result; } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } function getUnionIndexType(types, kind) { var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { @@ -15679,9 +15908,6 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* Union */) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512 /* TypeParameter */) { do { type = getConstraintOfTypeParameter(type); @@ -15699,7 +15925,7 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 4194304 /* ESSymbol */) { + else if (type.flags & 16777216 /* ESSymbol */) { type = globalESSymbolType; } return type; @@ -15784,6 +16010,29 @@ var ts; } return undefined; } + // Check if a property with the given name is known anywhere in the given type. In an object + // type, a property is considered known if the object type is empty, if it has any index + // signatures, or if the property is actually declared in the type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); @@ -15791,8 +16040,10 @@ var ts; } return emptyArray; } - // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - // maps primitive types and type parameters are to their apparent types. + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } @@ -15845,12 +16096,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15859,14 +16120,18 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8 /* StringLiteral */) { + if (param.type && param.type.kind === 9 /* StringLiteral */) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -15878,7 +16143,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147 /* TypePredicate */) { + if (declaration.type.kind === 148 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15890,8 +16155,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 === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); + if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15909,19 +16174,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* 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). @@ -15938,7 +16203,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16263,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 === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16012,7 +16277,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16041,13 +16306,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -16066,22 +16331,23 @@ var ts; return result; } } - // This function is used to propagate widening flags when creating new object types references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type - // of an object literal (since those types have widening related information we need to track). - function getWideningFlagsOfTypes(types) { + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728 /* RequiresWidening */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16100,16 +16366,16 @@ 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 === 134 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { + if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // Type parameters declared in a particular type parameter list @@ -16138,7 +16404,7 @@ var ts; var typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -16193,7 +16459,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16225,9 +16491,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: return declaration; } } @@ -16261,14 +16527,14 @@ var ts; } function tryGetGlobalType(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -16310,7 +16576,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -16338,20 +16604,71 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of + // a target type if the the two are identical, with the exception that the source type may have null or + // undefined in places where the target type doesn't. This is by design an asymmetric relationship. + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) { + return true; + } + if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -16374,29 +16691,26 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag - // is true when creating a union type from a type node and when instantiating a union type. In both of those - // cases subtype reduction has to be deferred to properly support recursive union types. For example, a - // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration. - function getUnionType(types, noSubtypeReduction) { + // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate + // based on the structure of the types unless the noDeduplication flag is true, which is the case when + // creating a union type from a type node and when instantiating a union type. In both of those cases, + // structural deduplication has to be deferred to properly support recursive union types. For example, + // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384 /* Union */); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -16404,37 +16718,19 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer - // to process and look strange in quick info and error messages. Semantically there is no difference between the - // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the - // type itself. - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); } return links.resolvedType; } - // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution @@ -16454,7 +16750,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -16491,47 +16787,47 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114 /* AnyKeyword */: + case 115 /* AnyKeyword */: return anyType; - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: return stringType; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: return numberType; - case 117 /* BooleanKeyword */: + case 118 /* BooleanKeyword */: return booleanType; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: return esSymbolType; - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return voidType; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return getTypeFromTypeReference(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return booleanType; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 155 /* UnionType */: + case 156 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* 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 66 /* Identifier */: - case 132 /* QualifiedName */: - var symbol = getSymbolInfo(node); + case 67 /* Identifier */: + case 133 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -16590,7 +16886,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -16599,6 +16895,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16689,7 +16987,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -16700,27 +16998,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 !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178 /* BinaryExpression */: - return node.operatorToken.kind === 50 /* BarBarToken */ && + case 179 /* BinaryExpression */: + return node.operatorToken.kind === 51 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16744,16 +17042,16 @@ var ts; } // TYPE CHECKING function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); @@ -16764,7 +17062,7 @@ var ts; function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -16809,6 +17107,15 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -16818,110 +17125,140 @@ var ts; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1 /* True */; - if (source === undefinedType) + if (source === numberType && target.flags & 128 /* Enum */) return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "each" checks on both sides because there may be nested "some" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - // Even if relationship doesn't hold for unions, type parameters, or generic type references, - // it may hold in a structural comparison. - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // Identity relation does not use apparent type - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { - // We clear the errors first because the following check often gives a better error than - // the union or intersection comparison above if it is applicable. - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, undefined, 128 /* UseFullyQualifiedType */); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0 /* False */; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; @@ -16992,31 +17329,18 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1 /* True */; - if (!(constraint && constraint.flags & 512 /* TypeParameter */)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0 /* False */; } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); } // Determine if two object types are related by structure. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. @@ -17211,26 +17535,20 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - var sourceSig = sourceSignatures[0]; - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -17255,6 +17573,33 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -17345,7 +17690,7 @@ var ts; } var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; } @@ -17358,7 +17703,7 @@ var ts; return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceType = getIndexTypeOfType(source, 0 /* String */); if (!sourceType) { if (reportErrors) { @@ -17382,7 +17727,7 @@ var ts; return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceStringType = getIndexTypeOfType(source, 0 /* String */); var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); if (!(sourceStringType || sourceNumberType)) { @@ -17469,14 +17814,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0 /* False */; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } } var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { @@ -17498,16 +17847,18 @@ var ts; // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0 /* False */; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -17573,6 +17924,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -17600,7 +17968,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } @@ -17655,7 +18023,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -17669,22 +18037,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135 /* Parameter */: + case 136 /* 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 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -17697,7 +18065,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17734,7 +18102,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -17758,11 +18128,16 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -17793,6 +18168,14 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; @@ -17959,10 +18342,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 151 /* TypeQuery */: + case 152 /* TypeQuery */: return true; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: node = node.parent; continue; default: @@ -18008,12 +18391,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { + if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { var n = node.left; - while (n.kind === 169 /* ParenthesizedExpression */) { + while (n.kind === 170 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18027,96 +18410,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 176 /* PrefixUnaryExpression */: - case 172 /* DeleteExpression */: - case 175 /* AwaitExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 177 /* PostfixUnaryExpression */: - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 189 /* Block */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: - case 237 /* JsxExpression */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 177 /* PrefixUnaryExpression */: + case 173 /* DeleteExpression */: + case 176 /* AwaitExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 178 /* PostfixUnaryExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 190 /* Block */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: + case 238 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - // Resolve location from top down towards node if it is a context sensitive expression - // That helps in making sure not assigning types as any when resolved out of order - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - // Get the narrowed type of symbol at given location instead of just getting - // the type of the symbol. - // eg. - // function foo(a: string | number) { - // if (typeof a === "string") { - // a/**/ - // } - // } - // getTypeOfSymbol for a would return type of parameter symbol string | number - // Unless we provide location /**/, checker wouldn't know how to narrow the type - // By using getNarrowedTypeOfSymbol would return string since it would be able to narrow - // it by typeguard in the if true condition - return getNarrowedTypeOfSymbol(symbol, node); - } // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); @@ -18128,37 +18475,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193 /* IfStatement */: + case 194 /* 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); + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 179 /* ConditionalExpression */: + case 180 /* 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); + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, true); + if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 50 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, false); + else if (node.operatorToken.kind === 51 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 245 /* SourceFile */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: + case 246 /* SourceFile */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18175,23 +18522,23 @@ 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 !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, - /*isOfTypeKind*/ true, false); + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Check was for a primitive type, return that primitive type if it is a subtype if (isTypeSubtypeOf(typeInfo.type, type)) { @@ -18199,12 +18546,12 @@ var ts; } // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is // union of enum types and other types. - return removeTypesFromUnionType(type, typeInfo.flags, false, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); } else { // Assumed result is false. If check was for a primitive type, remove that primitive type if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Otherwise we don't have enough information to do anything. return type; @@ -18213,14 +18560,14 @@ var ts; function narrowTypeByAnd(type, expr, assumeTrue) { if (assumeTrue) { // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, true), expr.right, true); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); } else { // The assumed result is false. This means either the first operand was false, or the first operand was true // and the second operand was false. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) ]); } } @@ -18229,18 +18576,18 @@ var ts; // The assumed result is true. This means either the first operand was true, or the first operand was false // and the second operand was true. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) ]); } else { // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, false), expr.right, false); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); } } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18276,13 +18623,17 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check if (originalType.flags & 16384 /* Union */) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; } return originalType; } @@ -18308,27 +18659,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165 /* CallExpression */: + case 166 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49 /* AmpersandAmpersandToken */) { + else if (operator === 50 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88 /* InstanceOfKeyword */) { + else if (operator === 89 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176 /* PrefixUnaryExpression */: - if (expr.operator === 47 /* ExclamationToken */) { + case 177 /* PrefixUnaryExpression */: + if (expr.operator === 48 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18346,7 +18697,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171 /* ArrowFunction */) { + if (container.kind === 172 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18377,7 +18728,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18386,19 +18737,19 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 209 /* VariableDeclarationList */) { + while (container.kind !== 210 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 190 /* VariableStatement */) { + if (container.kind === 191 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } var inFunction = isInsideFunction(node.parent, container); var current = container; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } @@ -18411,7 +18762,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { + if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18422,35 +18773,35 @@ var ts; function checkThisExpression(node) { // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, true); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 171 /* ArrowFunction */) { - container = ts.getThisContainer(container, false); + if (container.kind === 172 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* 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 214 /* EnumDeclaration */: + case 215 /* 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 141 /* Constructor */: + case 142 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18465,98 +18816,105 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135 /* Parameter */) { + if (n.kind === 136 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 172 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134 /* ComputedPropertyName */) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 141 /* Constructor */; + return container.kind === 142 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) // 'super' property access is allowed // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor - // super property access might appear in arrow functions with arbitrary deep nesting - needToCaptureLexicalThis = false; - while (container && container.kind === 171 /* 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 && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */; } else { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */ || - container.kind === 138 /* PropertyDeclaration */ || - container.kind === 137 /* PropertySignature */ || - container.kind === 141 /* Constructor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */ || + container.kind === 139 /* PropertyDeclaration */ || + container.kind === 138 /* PropertySignature */ || + container.kind === 142 /* Constructor */; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 512 /* SuperStatic */; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256 /* SuperInstance */; - returnType = baseClassType; - } - if (container.kind === 141 /* 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; - } - if (!isCallExpression && needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133 /* ComputedPropertyName */) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter) { @@ -18592,7 +18950,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18625,7 +18983,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18636,8 +18994,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 141 /* Constructor */ || - functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { + functionDecl.kind === 142 /* Constructor */ || + functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -18659,7 +19017,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167 /* TaggedTemplateExpression */) { + if (template.parent.kind === 168 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -18667,13 +19025,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -18769,7 +19127,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, undefined) : undefined); + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -18780,7 +19138,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 235 /* JsxAttribute */) { + if (expr.parent.kind === 236 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -18790,7 +19148,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236 /* JsxSpreadAttribute */) { + if (expr.kind === 237 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -18811,38 +19169,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 161 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 171 /* ArrowFunction */: - case 201 /* ReturnStatement */: + case 172 /* ArrowFunction */: + case 202 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 187 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); + case 188 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return getContextualType(parent); - case 237 /* JsxExpression */: - case 236 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 237 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -18859,7 +19217,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; + return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18873,7 +19231,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 !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18887,19 +19245,13 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - // The signature set of all constituent type with call signatures should match - // So number of signatures allowed is either 0 or 1 - if (signatureList && - getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { // Signatures aren't identical, do not use return undefined; } @@ -18919,23 +19271,36 @@ var ts; } return result; } - // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is - // used as a special marker for other purposes. + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 242 /* PropertyAssignment */) { + if (parent.kind === 243 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161 /* ArrayLiteralExpression */) { + if (parent.kind === 162 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18948,7 +19313,7 @@ var ts; // So the fact that contextualMapper is passed is not important, because the operand of a spread // element is not contextually typed. var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -18960,7 +19325,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18975,7 +19340,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -18984,7 +19349,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -18995,7 +19360,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 /* 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, @@ -19035,11 +19400,11 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); } } return links.resolvedType; @@ -19054,18 +19419,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 === 242 /* PropertyAssignment */ || - memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 243 /* PropertyAssignment */ || + memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242 /* PropertyAssignment */) { + if (memberDecl.kind === 243 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140 /* MethodDeclaration */) { + else if (memberDecl.kind === 141 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19085,7 +19450,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 === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19096,7 +19461,7 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); + result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -19129,35 +19494,39 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66 /* Identifier */) { + if (lhs.kind === 67 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); // Check that the closing tag matches if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: checkJsxExpression(child); break; - case 230 /* JsxElement */: + case 231 /* JsxElement */: checkJsxElement(child); break; - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 233 /* JsxText */); + ts.Debug.assert(child.kind === 234 /* JsxText */); } } return jsxElementType || anyType; @@ -19173,7 +19542,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132 /* QualifiedName */) { + if (tagName.kind === 133 /* QualifiedName */) { return false; } else { @@ -19190,10 +19559,19 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -19269,7 +19647,7 @@ var ts; return intrinsicElementsType.symbol; } // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -19279,22 +19657,24 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; + var valueSymbol = resolveJsxTagName(node); // Look up the value in the current scope - if (node.tagName.kind === 66 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -19302,10 +19682,9 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued @@ -19324,15 +19703,10 @@ var ts; if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { @@ -19347,7 +19721,7 @@ var ts; /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); // JSX.ElementAttributesProperty [symbol] var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] @@ -19383,7 +19757,7 @@ var ts; if (links.jsxFlags & 4 /* ClassElement */) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -19465,7 +19839,7 @@ var ts; // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -19477,11 +19851,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235 /* JsxAttribute */) { + if (node.attributes[i].kind === 236 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19511,7 +19885,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 : 138 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19527,8 +19901,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92 /* SuperKeyword */) { - var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + if (left.kind === 93 /* SuperKeyword */) { + var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19538,7 +19912,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 (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -19571,7 +19945,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 92 /* SuperKeyword */) { + if (left.kind === 93 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -19621,7 +19995,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 /* PropertyAccessExpression */ + var left = node.kind === 164 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -19637,7 +20011,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 167 /* 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); @@ -19656,7 +20030,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8 /* StringLiteral */)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -19684,7 +20058,7 @@ var ts; } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -19714,10 +20088,10 @@ var ts; * Otherwise, returns undefined. */ function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 /* StringLiteral */ || indexArgumentExpression.kind === 7 /* NumericLiteral */) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); } @@ -19739,7 +20113,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -19766,10 +20140,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 136 /* Decorator */) { + else if (node.kind !== 137 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -19799,13 +20173,13 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } @@ -19813,7 +20187,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -19835,7 +20209,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182 /* SpreadElementExpression */) { + if (arg && arg.kind === 183 /* SpreadElementExpression */) { return i; } } @@ -19847,13 +20221,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* 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 === 180 /* TemplateExpression */) { + if (tagExpression.template.kind === 181 /* 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; @@ -19866,20 +20240,20 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { isDecorator = true; typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -19922,7 +20296,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -19958,7 +20332,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20017,14 +20391,14 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { - argType = arg.kind === 8 /* StringLiteral */ && !reportErrors + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -20049,16 +20423,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20083,25 +20457,25 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 135 /* Parameter */: + case 136 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20126,25 +20500,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135 /* Parameter */: + case 136 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20173,35 +20547,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 66 /* Identifier */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 67 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -20227,18 +20601,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20271,10 +20645,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20286,8 +20660,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 136 /* Decorator */ || - (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { + if (node.kind === 137 /* Decorator */ || + (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20296,11 +20670,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20309,13 +20683,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 136 /* Decorator */; + var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 137 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 92 /* SuperKeyword */) { + if (node.expression.kind !== 93 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20412,17 +20786,18 @@ var ts; // in arguments too early. If possible, we'd like to only type them once we know the correct // overload. However, this matters for the case where the call is correct. When the call is // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -20441,6 +20816,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -20463,7 +20841,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) : undefined; while (true) { candidate = originalCandidate; @@ -20471,7 +20849,7 @@ var ts; var typeArgumentTypes = void 0; if (typeArguments) { typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); @@ -20483,7 +20861,7 @@ var ts; } candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; @@ -20518,7 +20896,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -20592,7 +20970,7 @@ var ts; // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */); if (valueDecl && valueDecl.flags & 256 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -20651,16 +21029,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135 /* Parameter */: + case 136 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -20697,16 +21075,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165 /* CallExpression */) { + if (node.kind === 166 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166 /* NewExpression */) { + else if (node.kind === 167 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 168 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -20724,15 +21102,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { return voidType; } - if (node.kind === 166 /* NewExpression */) { + if (node.kind === 167 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 /* Constructor */ && - declaration.kind !== 145 /* ConstructSignature */ && - declaration.kind !== 150 /* ConstructorType */) { + declaration.kind !== 142 /* Constructor */ && + declaration.kind !== 146 /* ConstructSignature */ && + declaration.kind !== 151 /* 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); @@ -20746,7 +21124,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -20765,13 +21143,51 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -20791,7 +21207,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189 /* Block */) { + if (func.body.kind !== 190 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -20910,7 +21326,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -20925,7 +21341,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 !== 189 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { return; } var bodyBlock = func.body; @@ -20943,10 +21359,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 !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -20959,37 +21375,44 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21011,7 +21434,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { checkSourceElement(node.body); } else { @@ -21057,24 +21480,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 66 /* Identifier */: { + case 67 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // 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 163 /* PropertyAccessExpression */: { + case 164 /* 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 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21082,22 +21505,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: { + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 164 /* ElementAccessExpression */: { + case 165 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8 /* StringLiteral */) { + if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21141,17 +21564,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return booleanType; - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21217,7 +21640,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -21231,7 +21654,7 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { @@ -21243,7 +21666,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21268,12 +21691,12 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21298,7 +21721,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { + if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21311,14 +21734,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161 /* ArrayLiteralExpression */) { + if (target.kind === 162 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21326,38 +21749,38 @@ var ts; function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36 /* AsteriskToken */: - case 57 /* AsteriskEqualsToken */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 38 /* PercentToken */: - case 59 /* PercentEqualsToken */: - case 35 /* MinusToken */: - case 56 /* MinusEqualsToken */: - case 41 /* LessThanLessThanToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: + case 37 /* AsteriskToken */: + case 58 /* AsteriskEqualsToken */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 39 /* PercentToken */: + case 60 /* PercentEqualsToken */: + case 36 /* MinusToken */: + case 57 /* MinusEqualsToken */: + case 42 /* LessThanLessThanToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -21385,8 +21808,8 @@ var ts; } } return numberType; - case 34 /* PlusToken */: - case 55 /* PlusEqualsToken */: + case 35 /* PlusToken */: + case 56 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -21420,44 +21843,44 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55 /* PlusEqualsToken */) { + if (operator === 56 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88 /* InstanceOfKeyword */: + case 89 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 87 /* InKeyword */: + case 88 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return rightType; - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 54 /* EqualsToken */: + case 55 /* EqualsToken */: checkAssignmentOperator(rightType); - return rightType; - case 23 /* CommaToken */: + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: return rightType; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21467,21 +21890,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - return 50 /* BarBarToken */; - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - return 32 /* ExclamationEqualsEqualsToken */; - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: - return 49 /* AmpersandAmpersandToken */; + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + return 51 /* BarBarToken */; + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + return 33 /* ExclamationEqualsEqualsToken */; + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: + return 50 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -21492,7 +21915,7 @@ var ts; // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); } } } @@ -21530,7 +21953,7 @@ var ts; // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { @@ -21542,10 +21965,10 @@ var ts; if (func.type) { var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); } } } @@ -21588,7 +22011,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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -21599,14 +22022,14 @@ 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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -21629,7 +22052,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -21641,9 +22064,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 67 /* Identifier */ || node.kind === 133 /* 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); } @@ -21657,78 +22080,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkIdentifier(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return checkThisExpression(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return checkSuperExpression(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return nullType; - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return booleanType; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return checkTemplateExpression(node); - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return stringType; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return checkCallExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return checkClassExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return checkAssertion(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkDeleteExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return checkVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return checkAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return undefinedType; - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return checkYieldExpression(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return checkJsxExpression(node); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return checkJsxElement(node); - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 232 /* JsxOpeningElement */: + case 233 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -21757,7 +22180,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -21774,15 +22197,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 /* MethodDeclaration */ || - node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */; + return node.kind === 141 /* MethodDeclaration */ || + node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 /* Identifier */ && + if (param.name.kind === 67 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -21792,31 +22215,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 171 /* ArrowFunction */: - case 144 /* CallSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 149 /* FunctionType */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 172 /* ArrowFunction */: + case 145 /* CallSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 150 /* FunctionType */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || - node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || - node.kind === 145 /* ConstructSignature */) { + else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || + node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || + node.kind === 146 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147 /* TypePredicate */) { + if (node.type.kind === 148 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -21825,7 +22248,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -21835,19 +22258,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 /* ObjectBindingPattern */ || - param.name.kind === 159 /* ArrayBindingPattern */) { + if (param.name.kind === 159 /* ObjectBindingPattern */ || + param.name.kind === 160 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 /* Identifier */ && + if (element.name.kind === 67 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 /* ArrayBindingPattern */ || - element.name.kind === 158 /* ObjectBindingPattern */) { + else if (element.name.kind === 160 /* ArrayBindingPattern */ || + element.name.kind === 159 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -21871,10 +22294,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -21902,7 +22325,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212 /* InterfaceDeclaration */) { + if (node.kind === 213 /* 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 @@ -21922,7 +22345,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -21930,7 +22353,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22402,80 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; + return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 162 /* ObjectLiteralExpression */: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94 /* ThisKeyword */) { + if (n.kind === 95 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { + else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 /* PropertyDeclaration */ && + return n.kind === 139 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { - // The first statement in the body of a constructor must be a super call if both of the following are true: + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { 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 { // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -22037,7 +22484,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142 /* GetAccessor */) { + if (node.kind === 143 /* 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); } @@ -22045,7 +22492,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 === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; + var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22141,9 +22588,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 === 212 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22161,7 +22608,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22247,7 +22694,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 === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); + ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* 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); @@ -22283,7 +22730,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22294,7 +22741,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 === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { + if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22378,8 +22825,6 @@ var ts; if (!produceDiagnostics) { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. // if localSymbol is defined on node then node itself is exported - check is required var symbol = node.localSymbol; if (!symbol) { @@ -22397,38 +22842,55 @@ var ts; } // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1 /* Export */)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 215 /* ModuleDeclaration */: - return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 216 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22505,7 +22967,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); @@ -22672,22 +23134,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135 /* Parameter */: + case 136 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -22700,9 +23162,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 148 /* TypeReference */) { + if (node && node.kind === 149 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); + var rootSymbol = resolveName(root, root.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { markAliasSymbolAsReferenced(rootSymbol); } @@ -22714,19 +23176,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 135 /* Parameter */: + case 136 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -22755,25 +23217,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 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 143 /* SetAccessor */: - case 142 /* GetAccessor */: - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 144 /* SetAccessor */: + case 143 /* GetAccessor */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135 /* Parameter */) { + if (node.kind === 136 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -22799,7 +23261,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 === 133 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -22848,11 +23310,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -22871,12 +23333,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 /* PropertyDeclaration */ || - node.kind === 137 /* PropertySignature */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */) { + if (node.kind === 139 /* PropertyDeclaration */ || + node.kind === 138 /* PropertySignature */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -22885,7 +23347,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -22901,7 +23363,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 66 /* Identifier */; + var isDeclaration_1 = node.kind !== 67 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -22924,7 +23386,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66 /* Identifier */; + var isDeclaration_2 = node.kind !== 67 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -22938,12 +23400,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 216 /* 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 === 245 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 246 /* 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_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -22978,27 +23440,27 @@ 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 === 208 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 191 /* 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 === 189 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 216 /* ModuleBlock */ || - container.kind === 215 /* ModuleDeclaration */ || - container.kind === 245 /* SourceFile */); + (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 217 /* ModuleBlock */ || + container.kind === 216 /* ModuleDeclaration */ || + container.kind === 246 /* 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 @@ -23013,18 +23475,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66 /* Identifier */) { + if (n.kind === 67 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // 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 === 135 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23050,7 +23512,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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23061,14 +23523,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -23078,7 +23540,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -23090,13 +23552,13 @@ var ts; error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { + if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23119,7 +23581,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23157,12 +23619,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23182,14 +23644,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 === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* 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 === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* 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. @@ -23197,14 +23659,14 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } } } @@ -23218,7 +23680,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 === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* 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); @@ -23232,7 +23694,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 === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -23261,7 +23723,7 @@ var ts; } function checkRightHandSideOfForOf(rhsExpression) { var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); } function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { if (isTypeAny(inputType)) { @@ -23404,8 +23866,8 @@ var ts; if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { return type.typeArguments[0]; } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); } /** * This function does the following steps: @@ -23428,7 +23890,7 @@ var ts; ts.Debug.assert(languageVersion < 2 /* ES6 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, true, true); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); var hasStringConstituent = arrayOrStringType !== arrayType; var reportedError = false; if (hasStringConstituent) { @@ -23471,7 +23933,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); + return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -23494,10 +23956,10 @@ var ts; // for generators. return; } - if (func.kind === 143 /* SetAccessor */) { + if (func.kind === 144 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141 /* Constructor */) { + else if (func.kind === 142 /* 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); } @@ -23533,7 +23995,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 === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -23545,14 +24007,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 239 /* 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. var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -23566,7 +24028,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 205 /* 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; @@ -23596,7 +24058,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -23671,7 +24133,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 === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -23842,7 +24304,7 @@ var ts; // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. @@ -23890,7 +24352,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; + return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -23960,7 +24422,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* 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); @@ -23981,7 +24443,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24014,32 +24476,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -24050,22 +24492,48 @@ var ts; }); nodeLinks.flags |= 8192 /* EnumValuesComputed */; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176 /* PrefixUnaryExpression */: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177 /* PrefixUnaryExpression */: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34 /* PlusToken */: return value; - case 35 /* MinusToken */: return -value; - case 48 /* TildeToken */: return ~value; + case 35 /* PlusToken */: return value_1; + case 36 /* MinusToken */: return -value_1; + case 49 /* TildeToken */: return ~value_1; } return undefined; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24075,41 +24543,41 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45 /* BarToken */: return left | right; - case 44 /* AmpersandToken */: return left & right; - case 42 /* GreaterThanGreaterThanToken */: return left >> right; - case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 41 /* LessThanLessThanToken */: return left << right; - case 46 /* CaretToken */: return left ^ right; - case 36 /* AsteriskToken */: return left * right; - case 37 /* SlashToken */: return left / right; - case 34 /* PlusToken */: return left + right; - case 35 /* MinusToken */: return left - right; - case 38 /* PercentToken */: return left % right; + case 46 /* BarToken */: return left | right; + case 45 /* AmpersandToken */: return left & right; + case 43 /* GreaterThanGreaterThanToken */: return left >> right; + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 42 /* LessThanLessThanToken */: return left << right; + case 47 /* CaretToken */: return left ^ right; + case 37 /* AsteriskToken */: return left * right; + case 38 /* SlashToken */: return left / right; + case 35 /* PlusToken */: return left + right; + case 36 /* MinusToken */: return left - right; + case 39 /* PercentToken */: return left % right; } return undefined; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return +e.text; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 66 /* Identifier */: - case 164 /* ElementAccessExpression */: - case 163 /* PropertyAccessExpression */: + case 67 /* Identifier */: + case 165 /* ElementAccessExpression */: + case 164 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66 /* Identifier */) { + if (e.kind === 67 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type - enumType = currentType; + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164 /* ElementAccessExpression */) { + if (e.kind === 165 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8 /* StringLiteral */) { + e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; } expression = e.expression; @@ -24122,26 +24590,26 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 66 /* Identifier */) { + if (current.kind === 67 /* Identifier */) { break; } - else if (current.kind === 163 /* PropertyAccessExpression */) { + else if (current.kind === 164 /* PropertyAccessExpression */) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); + enumType_1 = checkExpression(expression); // allow references to constant members of other enums - if (!(enumType.symbol && (enumType.symbol.flags & 384 /* Enum */))) { + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8 /* EnumMember */)) { return undefined; } @@ -24152,6 +24620,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24664,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 !== 214 /* EnumDeclaration */) { + if (declaration.kind !== 215 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24217,8 +24687,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 /* ClassDeclaration */ || - (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 /* ClassDeclaration */ || + (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24241,7 +24711,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -24250,7 +24720,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -24274,7 +24744,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24294,28 +24764,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { node = node.left; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8 /* StringLiteral */) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -24338,7 +24808,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 === 227 /* ExportSpecifier */ ? + var message = node.kind === 228 /* 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)); @@ -24365,7 +24835,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24402,7 +24872,7 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.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); } @@ -24422,8 +24892,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24437,7 +24907,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { + if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -24452,8 +24922,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { + var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -24461,7 +24931,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { markExportAsReferenced(node); } else { @@ -24480,10 +24950,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245 /* SourceFile */) { + if (node.kind === 246 /* SourceFile */) { return node.statements; } - if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -24522,118 +24992,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return checkTypeParameter(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return checkParameter(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return checkPropertyDeclaration(node); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return checkSignatureDeclaration(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return checkMethodDeclaration(node); - case 141 /* Constructor */: + case 142 /* Constructor */: return checkConstructorDeclaration(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return checkAccessorDeclaration(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return checkTypeReferenceNode(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return checkTypePredicate(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return checkTypeQuery(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return checkTypeLiteral(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return checkArrayType(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return checkTupleType(node); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return checkSourceElement(node.type); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return checkBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return checkVariableStatement(node); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return checkExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return checkIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return checkDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return checkWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return checkForStatement(node); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return checkForInStatement(node); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return checkForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return checkReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return checkSwitchStatement(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return checkLabeledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return checkThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return checkTryStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return checkBindingElement(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return checkClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return checkImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return checkExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return checkExportAssignment(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -24648,95 +25118,95 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202 /* WithStatement */: + case 203 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136 /* Decorator */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 160 /* BindingElement */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 180 /* TemplateExpression */: - case 187 /* TemplateSpan */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 175 /* AwaitExpression */: - case 172 /* DeleteExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 181 /* YieldExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 217 /* CaseBlock */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 208 /* VariableDeclaration */: - case 209 /* VariableDeclarationList */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 224 /* ExportAssignment */: - case 245 /* SourceFile */: - case 237 /* JsxExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: + case 137 /* Decorator */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 161 /* BindingElement */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 181 /* TemplateExpression */: + case 188 /* TemplateSpan */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 176 /* AwaitExpression */: + case 173 /* DeleteExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 182 /* YieldExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 218 /* CaseBlock */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 209 /* VariableDeclaration */: + case 210 /* VariableDeclarationList */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 225 /* ExportAssignment */: + case 246 /* SourceFile */: + case 238 /* JsxExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -24822,7 +25292,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -24845,25 +25315,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -24872,13 +25342,16 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -24912,43 +25385,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 /* Identifier */ && + return name.kind === 67 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134 /* TypeParameter */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 135 /* TypeParameter */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* 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 === 132 /* QualifiedName */) { + while (node.parent && node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 148 /* TypeReference */; + return node.parent && node.parent.kind === 149 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -24960,11 +25433,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224 /* ExportAssignment */) { + if (entityName.parent.kind === 225 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 163 /* PropertyAccessExpression */) { + if (entityName.kind !== 164 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -24974,11 +25447,13 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || + (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 235 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -24986,20 +25461,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163 /* PropertyAccessExpression */) { + else if (entityName.kind === 164 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132 /* QualifiedName */) { + else if (entityName.kind === 133 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25008,22 +25483,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235 /* JsxAttribute */) { + else if (entityName.parent.kind === 236 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147 /* TypePredicate */) { - return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + if (entityName.parent.kind === 148 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -25032,39 +25507,50 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 /* BindingElement */ && + node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 118 /* ConstructorKeyword */: + case 119 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && + ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25081,7 +25567,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 === 243 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25103,28 +25589,28 @@ var ts; return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; } if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -25195,11 +25681,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25214,11 +25700,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return true; } return false; @@ -25229,7 +25715,7 @@ var ts; if (links.isNestedRedeclaration === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -25248,22 +25734,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224 /* ExportAssignment */: - return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225 /* ExportAssignment */: + return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25276,7 +25762,11 @@ var ts; return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -25321,7 +25811,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244 /* EnumMember */) { + if (node.kind === 245 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25336,14 +25826,16 @@ var ts; function isFunctionType(type) { return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(node) { + function getTypeReferenceSerializationKind(typeName) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25857,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -25400,7 +25892,7 @@ var ts; function getReferencedValueSymbol(reference) { return getNodeLinks(reference).resolvedSymbol || resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, undefined); + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); @@ -25409,13 +25901,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* 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); + resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -25457,7 +25949,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +25970,7 @@ var ts; getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types - globalArrayType = getGlobalType("Array", 1); + globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -25489,10 +25982,10 @@ var ts; getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); @@ -25503,9 +25996,9 @@ var ts; globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; @@ -25549,7 +26042,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 === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { + else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* 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); @@ -25559,38 +26052,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 215 /* ModuleDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 135 /* Parameter */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 216 /* ModuleDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 136 /* Parameter */: break; - case 210 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 211 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 190 /* VariableStatement */: - case 213 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 191 /* VariableStatement */: + case 214 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 214 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 215 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -25605,14 +26098,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 108 /* ProtectedKeyword */: - case 107 /* PrivateKeyword */: + case 110 /* PublicKeyword */: + case 109 /* ProtectedKeyword */: + case 108 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 109 /* PublicKeyword */) { + if (modifier.kind === 110 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 108 /* ProtectedKeyword */) { + else if (modifier.kind === 109 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -25629,11 +26122,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 107 /* PrivateKeyword */) { + if (modifier.kind === 108 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -25642,17 +26135,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -25661,7 +26154,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -25674,42 +26167,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211 /* ClassDeclaration */) { - if (node.kind !== 140 /* MethodDeclaration */) { + if (node.kind !== 212 /* ClassDeclaration */) { + if (node.kind !== 141 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -25721,14 +26214,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -25736,7 +26229,7 @@ var ts; break; } } - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -25754,10 +26247,10 @@ var ts; } return; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -25769,10 +26262,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140 /* MethodDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -25820,16 +26313,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -25840,7 +26331,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171 /* ArrowFunction */) { + if (node.kind === 172 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -25875,7 +26366,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 !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { + if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -25908,7 +26399,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184 /* OmittedExpression */) { + if (arg.kind === 185 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -25935,7 +26426,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -25948,7 +26439,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -25964,14 +26455,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -25982,19 +26473,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 133 /* ComputedPropertyName */) { + if (node.kind !== 134 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26020,8 +26511,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 /* OmittedExpression */ || - name_16.kind === 133 /* ComputedPropertyName */) { + if (prop.kind === 185 /* OmittedExpression */ || + name_16.kind === 134 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; @@ -26035,21 +26526,21 @@ 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 === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { + if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7 /* NumericLiteral */) { + if (name_16.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140 /* MethodDeclaration */) { + else if (prop.kind === 141 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 142 /* GetAccessor */) { + else if (prop.kind === 143 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 143 /* SetAccessor */) { + else if (prop.kind === 144 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26081,7 +26572,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236 /* JsxSpreadAttribute */) { + if (attr.kind === 237 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26093,7 +26584,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26102,24 +26593,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* 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 === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* 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 === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* 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); @@ -26142,10 +26633,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143 /* SetAccessor */) { + else if (kind === 144 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26170,7 +26661,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26180,7 +26671,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.parent.kind === 163 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26204,22 +26695,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 === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* 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 === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* 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 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return true; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26231,26 +26722,26 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204 /* LabeledStatement */: + case 205 /* 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 === 199 /* ContinueStatement */ - && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 203 /* SwitchStatement */: - if (node.kind === 200 /* BreakStatement */ && !node.label) { + case 204 /* SwitchStatement */: + if (node.kind === 201 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } break; default: - if (isIterationStatement(current, false) && !node.label) { + if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { // unlabeled break or continue within iteration statement - ok return false; } @@ -26259,13 +26750,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* 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 === 200 /* BreakStatement */ + var message = node.kind === 201 /* 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); @@ -26277,7 +26768,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { + if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26287,7 +26778,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { + if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26314,7 +26805,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26323,7 +26814,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26340,15 +26831,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return false; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26364,13 +26855,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176 /* PrefixUnaryExpression */) { + if (expression.kind === 177 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 7 /* NumericLiteral */) { + if (expression.kind === 8 /* NumericLiteral */) { // Allows for scientific notation since literalExpression.text was formed by // coercing a number to a string. Sometimes this coercion can yield a string // in scientific notation. @@ -26393,7 +26884,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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -26436,7 +26927,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -26456,12 +26947,12 @@ var ts; return true; } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* 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 === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* 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; } @@ -26481,11 +26972,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 212 /* InterfaceDeclaration */ || - node.kind === 219 /* ImportDeclaration */ || - node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ExportDeclaration */ || - node.kind === 224 /* ExportAssignment */ || + if (node.kind === 213 /* InterfaceDeclaration */ || + node.kind === 220 /* ImportDeclaration */ || + node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ExportDeclaration */ || + node.kind === 225 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -26495,7 +26986,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 === 190 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -26521,7 +27012,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 === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -26542,7 +27033,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } } @@ -26603,7 +27094,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -26679,10 +27170,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208 /* VariableDeclaration */) { + if (declaration.kind === 209 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { + else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -26700,7 +27191,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 === 219 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 220 /* 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; @@ -26710,12 +27201,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -26798,7 +27289,7 @@ var ts; var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -26807,49 +27298,49 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 8 /* StringLiteral */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return emitTypeReference(type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return emitTypeQuery(type); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return emitArrayType(type); - case 154 /* TupleType */: + case 155 /* TupleType */: return emitTupleType(type); - case 155 /* UnionType */: + case 156 /* UnionType */: return emitUnionType(type); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return emitIntersectionType(type); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return emitParenType(type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return emitTypeLiteral(type); - case 66 /* Identifier */: + case 67 /* Identifier */: return emitEntityName(type); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitEntityName(type); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -26858,13 +27349,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -26945,7 +27436,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -26965,7 +27456,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -26984,10 +27475,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 /* ImportEqualsDeclaration */ || - (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 /* ImportEqualsDeclaration */ || + (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -26997,7 +27488,7 @@ var ts; }); } else { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27015,23 +27506,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return writeVariableStatement(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return writeClassDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27047,7 +27538,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 212 /* InterfaceDeclaration */) { + else if (node.kind !== 213 /* InterfaceDeclaration */) { write("declare "); } } @@ -27096,7 +27587,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221 /* NamespaceImport */) { + if (namedBindings.kind === 222 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27124,7 +27615,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27182,7 +27673,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216 /* ModuleBlock */) { + while (node.body.kind !== 217 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27199,14 +27690,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -27243,7 +27738,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27254,15 +27749,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 === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || - node.parent.kind === 139 /* MethodSignature */ || - node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.kind === 144 /* CallSignature */ || - node.parent.kind === 145 /* ConstructSignature */); + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || + node.parent.kind === 140 /* MethodSignature */ || + node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.kind === 145 /* CallSignature */ || + node.parent.kind === 146 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27273,31 +27768,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 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* 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 === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* 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 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27328,7 +27823,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + if (node.parent.parent.kind === 212 /* 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 : @@ -27368,9 +27863,9 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -27389,7 +27884,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); write(" {"); writeLine(); increaseIndent(); @@ -27412,7 +27907,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 !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -27422,10 +27917,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -27434,14 +27929,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* 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 === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { + else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -27450,7 +27945,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 === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* 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 : @@ -27482,7 +27977,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { elements.push(element); } } @@ -27503,7 +27998,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28047,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 === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -27565,7 +28060,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 /* GetAccessor */ + return accessor.kind === 143 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -27574,7 +28069,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 144 /* 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 ? @@ -27624,17 +28119,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140 /* MethodDeclaration */) { + else if (node.kind === 141 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141 /* Constructor */) { + else if (node.kind === 142 /* Constructor */) { write("constructor"); } else { @@ -27652,11 +28147,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { + if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("["); } else { @@ -27666,22 +28161,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -27692,26 +28187,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* 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 144 /* CallSignature */: + case 145 /* 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 146 /* IndexSignature */: + case 147 /* 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 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27719,7 +28214,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 === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* 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 : @@ -27733,7 +28228,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210 /* FunctionDeclaration */: + case 211 /* 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 : @@ -27764,13 +28259,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.parent.kind === 152 /* TypeLiteral */) { + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -27786,24 +28281,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141 /* Constructor */: + case 142 /* 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 145 /* ConstructSignature */: + case 146 /* 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 144 /* CallSignature */: + case 145 /* 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 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27811,7 +28306,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 === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* 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 : @@ -27824,7 +28319,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 210 /* FunctionDeclaration */: + case 211 /* 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 : @@ -27836,12 +28331,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 === 158 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -27860,7 +28355,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184 /* OmittedExpression */) { + if (bindingElement.kind === 185 /* 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) @@ -27869,7 +28364,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 160 /* BindingElement */) { + else if (bindingElement.kind === 161 /* 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" @@ -27879,10 +28374,8 @@ var ts; // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. // In the case of rest element, we will omit rest element. @@ -27894,7 +28387,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -27910,40 +28403,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 212 /* InterfaceDeclaration */: - case 211 /* ClassDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 211 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 213 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, !node.importClause); - case 225 /* ExportDeclaration */: + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return writeFunctionDeclaration(node); - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessorDeclaration(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return emitPropertyDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFile(node); } } @@ -27952,7 +28445,7 @@ var ts; ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); referencePathsOutput += "/// " + newLine; @@ -28026,18 +28519,18 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || 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, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } // Sort and make the unique list of diagnostics @@ -28100,7 +28593,7 @@ var ts; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; /** Emit a node */ - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ var emitStart = function (node) { }; /** Called once the emit of the node is done */ @@ -28135,7 +28628,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28688,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 /* StringLiteral */ ? + var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -28207,19 +28700,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return makeUniqueName(node.text); - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 219 /* ImportDeclaration */: - case 225 /* ExportDeclaration */: + case 220 /* ImportDeclaration */: + case 226 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: - case 224 /* ExportAssignment */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 225 /* ExportAssignment */: return generateNameForExportDefault(); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28285,7 +28778,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -28391,7 +28884,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_21 = node.name; - if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -28409,20 +28902,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */ || - node.kind === 215 /* ModuleDeclaration */ || - node.kind === 211 /* ClassDeclaration */ || - node.kind === 214 /* EnumDeclaration */) { + else if (node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */ || + node.kind === 216 /* ModuleDeclaration */ || + node.kind === 212 /* ClassDeclaration */ || + node.kind === 215 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 133 /* ComputedPropertyName */ + scopeName = name_22.kind === 134 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -28481,7 +28974,7 @@ var ts; } else { // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; } // Write sourcemap url to the js file and write the js file @@ -28517,7 +29010,9 @@ var ts; 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, + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); } else { @@ -28532,7 +29027,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245 /* SourceFile */) { + if (node.kind !== 246 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -28543,8 +29038,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29055,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66 /* Identifier */); + var result = ts.createSynthesizedNode(67 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -28667,7 +29165,14 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -28680,11 +29185,11 @@ var ts; } function emitCommaList(nodes) { if (nodes) { - emitList(nodes, 0, nodes.length, false, false); + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); } } function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); + emitLinesStartingAt(nodes, /*startIndex*/ 0); } function emitLinesStartingAt(nodes, startIndex) { for (var i = startIndex; i < nodes.length; i++) { @@ -28693,7 +29198,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: @@ -28706,7 +29211,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -28720,7 +29225,7 @@ var ts; // 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, '"'); + 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. @@ -28730,17 +29235,17 @@ var ts; // 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 */: + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -28757,18 +29262,18 @@ var ts; // 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 */; + var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* 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 + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { literalEmitter(node.template); } else { @@ -28795,11 +29300,11 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 180 /* TemplateExpression */) { + if (node.template.kind === 181 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; + var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -28833,7 +29338,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 170 /* 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 @@ -28875,11 +29380,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent.expression === template; - case 167 /* TaggedTemplateExpression */: - case 169 /* ParenthesizedExpression */: + case 168 /* TaggedTemplateExpression */: + case 170 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -28900,20 +29405,20 @@ 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 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 1 /* GreaterThan */; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -28928,10 +29433,10 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28942,9 +29447,9 @@ var ts; /// about keywords, just non-identifier characters function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28976,37 +29481,37 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_2 === 0) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -29029,16 +29534,16 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 233 /* JsxText */) { + if (children[i].kind === 234 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -29051,11 +29556,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -29075,11 +29580,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29087,11 +29592,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231 /* JsxSelfClosingElement */) { + if (node.kind === 232 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29110,11 +29615,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29122,11 +29627,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 !== 160 /* BindingElement */); - if (node.kind === 8 /* StringLiteral */) { + ts.Debug.assert(node.kind !== 161 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 133 /* ComputedPropertyName */) { + else if (node.kind === 134 /* 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: @@ -29158,7 +29663,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29675,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161 /* ArrayLiteralExpression */: - case 178 /* BinaryExpression */: - case 165 /* CallExpression */: - case 238 /* CaseClause */: - case 133 /* ComputedPropertyName */: - case 179 /* ConditionalExpression */: - case 136 /* Decorator */: - case 172 /* DeleteExpression */: - case 194 /* DoStatement */: - case 164 /* ElementAccessExpression */: - case 224 /* ExportAssignment */: - case 192 /* ExpressionStatement */: - case 185 /* ExpressionWithTypeArguments */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 193 /* IfStatement */: - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: - case 166 /* NewExpression */: - case 169 /* ParenthesizedExpression */: - case 177 /* PostfixUnaryExpression */: - case 176 /* PrefixUnaryExpression */: - case 201 /* ReturnStatement */: - case 243 /* ShorthandPropertyAssignment */: - case 182 /* SpreadElementExpression */: - case 203 /* SwitchStatement */: - case 167 /* TaggedTemplateExpression */: - case 187 /* TemplateSpan */: - case 205 /* ThrowStatement */: - case 168 /* TypeAssertionExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 181 /* YieldExpression */: + case 162 /* ArrayLiteralExpression */: + case 179 /* BinaryExpression */: + case 166 /* CallExpression */: + case 239 /* CaseClause */: + case 134 /* ComputedPropertyName */: + case 180 /* ConditionalExpression */: + case 137 /* Decorator */: + case 173 /* DeleteExpression */: + case 195 /* DoStatement */: + case 165 /* ElementAccessExpression */: + case 225 /* ExportAssignment */: + case 193 /* ExpressionStatement */: + case 186 /* ExpressionWithTypeArguments */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 194 /* IfStatement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: + case 237 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 167 /* NewExpression */: + case 170 /* ParenthesizedExpression */: + case 178 /* PostfixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: + case 202 /* ReturnStatement */: + case 244 /* ShorthandPropertyAssignment */: + case 183 /* SpreadElementExpression */: + case 204 /* SwitchStatement */: + case 168 /* TaggedTemplateExpression */: + case 188 /* TemplateSpan */: + case 206 /* ThrowStatement */: + case 169 /* TypeAssertionExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 182 /* YieldExpression */: return true; - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 209 /* VariableDeclaration */: return parent.initializer === node; - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return parent.expression === node; - case 171 /* ArrowFunction */: - case 170 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 171 /* FunctionExpression */: return parent.body === node; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return parent.left === node; } return false; @@ -29233,7 +29740,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245 /* SourceFile */) { + if (container.kind === 246 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -29248,13 +29755,13 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220 /* ImportClause */) { + if (declaration.kind === 221 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223 /* ImportSpecifier */) { + else if (declaration.kind === 224 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); @@ -29272,13 +29779,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 208 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 209 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -29322,13 +29829,13 @@ var ts; function emitObjectBindingPattern(node) { write("{ "); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write(" }"); } function emitArrayBindingPattern(node) { write("["); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write("]"); } function emitBindingElement(node) { @@ -29352,7 +29859,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29366,7 +29873,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +29881,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66 /* Identifier */: - case 161 /* ArrayLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: + case 67 /* Identifier */: + case 162 /* ArrayLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 170 /* 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; @@ -29409,17 +29916,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182 /* SpreadElementExpression */) { + if (e.kind === 183 /* SpreadElementExpression */) { e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { i++; } write("["); @@ -29442,7 +29949,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182 /* SpreadElementExpression */; + return node.kind === 183 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -29451,12 +29958,12 @@ var ts; } else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, true); + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } function emitObjectLiteralBody(node, numElements) { @@ -29471,7 +29978,7 @@ var ts; // 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); + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; @@ -29481,7 +29988,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30019,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { + if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -29564,13 +30071,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242 /* PropertyAssignment */) { + if (property.kind === 243 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 243 /* ShorthandPropertyAssignment */) { + else if (property.kind === 244 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140 /* MethodDeclaration */) { + else if (property.kind === 141 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -29604,7 +30111,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 === 133 /* ComputedPropertyName */) { + if (properties[i].name.kind === 134 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -29620,21 +30127,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -29642,7 +30149,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { + while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -29654,11 +30161,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 /* NewExpression */ && - expr.kind !== 7 /* NumericLiteral */) { + expr.kind !== 167 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -29680,12 +30187,20 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245 /* SourceFile */; + return container && container.kind !== 246 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -29707,21 +30222,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - // do not inline enum values in separate compilation mode - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } // Returns 'true' if the code was actually indented, false otherwise. // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. @@ -29748,10 +30267,20 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -29769,7 +30298,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66 /* Identifier */) { + if (node.left.kind === 67 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -29777,19 +30306,19 @@ var ts; write("("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(node.left, true); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); write(") && "); emitNodeWithoutSourceMap(temp); } else { - emitEntityNameAsExpression(node.left, false); + emitEntityNameAsExpression(node.left, /*useFallback*/ false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -29797,7 +30326,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30341,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { + while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { + if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { emit(node); return node; } @@ -29836,20 +30365,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164 /* ElementAccessExpression */) { + else if (expr.kind === 165 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92 /* SuperKeyword */) { + else if (expr.kind === 93 /* SuperKeyword */) { target = expr; write("_super"); } @@ -29858,7 +30387,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92 /* SuperKeyword */) { + if (target.kind === 93 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -29872,7 +30401,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false, false, true); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } function emitCallExpression(node) { @@ -29881,13 +30410,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; + superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -29929,7 +30458,7 @@ var ts; write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } @@ -29956,12 +30485,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { - if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { + if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { + while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -29972,14 +30501,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 !== 176 /* PrefixUnaryExpression */ && - operand.kind !== 174 /* VoidExpression */ && - operand.kind !== 173 /* TypeOfExpression */ && - operand.kind !== 172 /* DeleteExpression */ && - operand.kind !== 177 /* PostfixUnaryExpression */ && - operand.kind !== 166 /* NewExpression */ && - !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && - !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { + if (operand.kind !== 177 /* PrefixUnaryExpression */ && + operand.kind !== 175 /* VoidExpression */ && + operand.kind !== 174 /* TypeOfExpression */ && + operand.kind !== 173 /* DeleteExpression */ && + operand.kind !== 178 /* PostfixUnaryExpression */ && + operand.kind !== 167 /* NewExpression */ && + !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && + !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) { emit(operand); return; } @@ -29990,29 +30519,29 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75 /* DeleteKeyword */)); + write(ts.tokenToString(76 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100 /* VoidKeyword */)); + write(ts.tokenToString(101 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98 /* TypeOfKeyword */)); + write(ts.tokenToString(99 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); } function emitPrefixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); @@ -30038,12 +30567,12 @@ 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 === 176 /* PrefixUnaryExpression */) { + if (node.operand.kind === 177 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { write(" "); } } @@ -30063,7 +30592,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39 /* PlusPlusToken */) { + if (node.operator === 40 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30076,7 +30605,7 @@ var ts; } } function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); } /* * Checks if given node is a source file level declaration (not nested in module/function). @@ -30094,10 +30623,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245 /* SourceFile */) { + if (current.kind === 246 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { return false; } else { @@ -30106,13 +30635,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && - (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && + (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && - node.operatorToken.kind <= 65 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && + node.operatorToken.kind <= 66 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30121,7 +30650,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -30160,36 +30689,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189 /* Block */) { + if (node && node.kind === 190 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); write(" "); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); return; } - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); + if (node.kind === 217 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216 /* ModuleBlock */) { - emitTempDeclarations(true); + if (node.kind === 217 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { write(" "); emit(node); } @@ -30201,20 +30730,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85 /* IfKeyword */, node.pos); + var endPos = emitToken(86 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 193 /* IfStatement */) { + emitToken(78 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 194 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30226,7 +30755,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { write(" "); } else { @@ -30248,17 +30777,17 @@ var ts; * in system modules where such variable declarations are hoisted. */ function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; } - var tokenKind = 99 /* VarKeyword */; + var tokenKind = 100 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 105 /* LetKeyword */; + tokenKind = 106 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 71 /* ConstKeyword */; + tokenKind = 72 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30267,13 +30796,13 @@ var ts; } else { switch (tokenKind) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: write("var "); break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: write("let "); break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: write("const "); break; } @@ -30298,10 +30827,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30322,13 +30851,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30338,14 +30867,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197 /* ForInStatement */) { + if (node.kind === 198 /* ForInStatement */) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -30369,9 +30898,9 @@ var ts; // 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(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* 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. @@ -30380,7 +30909,7 @@ var ts; // 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 === 66 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 67 /* 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 @@ -30405,7 +30934,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +30943,7 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); writeLine(); @@ -30423,7 +30952,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -30431,12 +30960,12 @@ var ts; 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); + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); } else { // The following call does not include the initializer, so we have // to emit it separately. - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -30452,19 +30981,19 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* 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); + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { emitLines(node.statement.statements); } else { @@ -30476,12 +31005,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91 /* ReturnKeyword */, node.pos); + emitToken(92 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -30492,21 +31021,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93 /* SwitchKeyword */, node.pos); + var endPos = emitToken(94 /* SwitchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(17 /* CloseParenToken */, node.expression.end); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14 /* OpenBraceToken */, startPos); + emitToken(15 /* OpenBraceToken */, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.clauses.end); + emitToken(16 /* CloseBraceToken */, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -30521,7 +31050,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238 /* CaseClause */) { + if (node.kind === 239 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -30556,16 +31085,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69 /* CatchKeyword */, node.pos); + var endPos = emitToken(70 /* CatchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); - emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73 /* DebuggerKeyword */, node.pos); + emitToken(74 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -30576,7 +31105,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215 /* ModuleDeclaration */); + } while (node && node.kind !== 216 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -30595,16 +31124,35 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(174 /* VoidExpression */); + var result = ts.createSynthesizedNode(175 /* VoidExpression */); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + // only allow export default at a source file level + if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1 /* Export */) { writeLine(); @@ -30618,7 +31166,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31174,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31193,36 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4 /* System */) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - 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); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4 /* System */); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.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 @@ -30677,15 +31230,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 208 /* VariableDeclaration */) { + if (root.kind === 209 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135 /* Parameter */) { + else if (root.kind === 136 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178 /* BinaryExpression */) { + if (root.kind === 179 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -30696,11 +31249,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -30716,7 +31269,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66 /* Identifier */) { + if (expr.kind !== 67 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -30731,23 +31284,23 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7 /* NumericLiteral */); + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); node.text = "" + value; return node; } @@ -30756,14 +31309,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66 /* Identifier */) { + if (syntheticName.kind !== 67 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); + var call = ts.createSynthesizedNode(166 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -30779,7 +31332,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -30794,8 +31347,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -30805,14 +31358,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161 /* ArrayLiteralExpression */) { + else if (target.kind === 162 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -30822,18 +31375,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write(")"); } } @@ -30857,12 +31413,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* 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 !== 184 /* OmittedExpression */) { + else if (element.kind !== 185 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -30881,7 +31437,7 @@ var ts; function emitVariableDeclaration(node) { if (ts.isBindingPattern(node.name)) { if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, false); + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); } else { emit(node.name); @@ -30901,15 +31457,15 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 197 /* ForInStatement */ && - node.parent.parent.kind !== 198 /* ForOfStatement */) { + node.parent.parent.kind !== 198 /* ForInStatement */ && + node.parent.parent.kind !== 199 /* ForOfStatement */) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -30920,11 +31476,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184 /* OmittedExpression */) { + if (node.kind === 185 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -30932,7 +31488,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -30940,7 +31496,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 245 /* SourceFile */; + node.parent.kind === 246 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31029,7 +31585,7 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); } else { emit(tempParameters[tempIndex]); @@ -31049,9 +31605,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31627,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31648,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,27 +31657,27 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170 /* FunctionExpression */) { + if (node.kind === 171 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* 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 */; } @@ -31130,10 +31686,25 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { - // Methods will emit the comments as part of emitting method declaration + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && + node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && + node.parent.kind !== 166 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression emitLeadingComments(node); } + emitStart(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)) { @@ -31153,10 +31724,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + emitEnd(node); + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31174,7 +31746,7 @@ var ts; if (node) { var parameters = node.parameters; var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); decreaseIndent(); @@ -31189,7 +31761,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var isArrowFunction = node.kind === 172 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -31310,7 +31882,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +31937,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 168 /* TypeAssertionExpression */) { + while (current.kind === 169 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -31388,7 +31960,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +31971,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +31988,7 @@ var ts; 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); + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); emitFunctionBodyPreamble(node); decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; @@ -31426,29 +31998,29 @@ var ts; write(" "); emit(statement); } - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); emitLeadingCommentsOfPosition(body.statements.end); } else { increaseIndent(); emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15 /* CloseBraceToken */, body.statements.end); + emitToken(16 /* CloseBraceToken */, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192 /* ExpressionStatement */) { + if (statement && statement.kind === 193 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 165 /* CallExpression */) { + if (expr && expr.kind === 166 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 92 /* SuperKeyword */) { + if (func && func.kind === 93 /* SuperKeyword */) { return statement; } } @@ -31472,25 +32044,27 @@ var ts; }); } 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 */) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133 /* ComputedPropertyName */) { + else if (memberName.kind === 134 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -31530,11 +32104,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188 /* SemicolonClassElement */) { + if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { + else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -31546,14 +32120,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { + else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -31603,22 +32175,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { + if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 /* MethodDeclaration */ || - member.kind === 142 /* GetAccessor */ || - member.kind === 143 /* SetAccessor */) { + else if (member.kind === 141 /* MethodDeclaration */ || + member.kind === 143 /* GetAccessor */ || + member.kind === 144 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 142 /* GetAccessor */) { + if (member.kind === 143 /* GetAccessor */) { write("get "); } - else if (member.kind === 143 /* SetAccessor */) { + else if (member.kind === 144 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -31629,7 +32201,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32226,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && !member.body) { + if (member.kind === 142 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -31697,18 +32269,23 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -31729,21 +32306,21 @@ var ts; emitEnd(baseTypeElement); } } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); if (ctor) { var statements = ctor.body.statements; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -31766,7 +32343,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* 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: @@ -31845,8 +32422,8 @@ 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 === 183 /* ClassExpression */; + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -31874,7 +32451,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* 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 @@ -31897,7 +32474,7 @@ var ts; var property = staticProperties[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); } write(","); writeLine(); @@ -31930,7 +32507,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -31965,23 +32542,23 @@ var ts; writeLine(); emitConstructor(node, baseTypeNode); emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end, function () { + emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -31989,11 +32566,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -32007,7 +32584,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32613,13 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); @@ -32085,7 +32662,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 140 /* MethodDeclaration */) { + if (member.kind === 141 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32123,7 +32700,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32138,7 +32715,7 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); @@ -32153,7 +32730,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32176,7 +32753,7 @@ var ts; var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); write("__param(" + parameterIndex + ", "); emit(decorator.expression); @@ -32195,10 +32772,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 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: return true; } return false; @@ -32208,7 +32785,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 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: return true; } return false; @@ -32218,9 +32795,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 211 /* ClassDeclaration */: - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return true; } return false; @@ -32238,19 +32815,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: write("Function"); return; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 135 /* Parameter */: + case 136 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32261,43 +32838,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: write("void 0"); return; - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: write("Function"); return; - case 153 /* ArrayType */: - case 154 /* TupleType */: + case 154 /* ArrayType */: + case 155 /* TupleType */: write("Array"); return; - case 147 /* TypePredicate */: - case 117 /* BooleanKeyword */: + case 148 /* TypePredicate */: + case 118 /* BooleanKeyword */: write("Boolean"); return; - case 127 /* StringKeyword */: - case 8 /* StringLiteral */: + case 128 /* StringKeyword */: + case 9 /* StringLiteral */: write("String"); return; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: write("Number"); return; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: write("Symbol"); return; - case 148 /* TypeReference */: + case 149 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 151 /* TypeQuery */: - case 152 /* TypeLiteral */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 114 /* AnyKeyword */: + case 152 /* TypeQuery */: + case 153 /* TypeLiteral */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 115 /* AnyKeyword */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -32307,21 +32887,27 @@ var ts; } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0 /* Auto */); write("(typeof ("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(typeName, true); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); write(") || Object"); break; case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); + emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; case ts.TypeReferenceSerializationKind.VoidType: write("void 0"); @@ -32364,7 +32950,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -32380,10 +32966,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153 /* ArrayType */) { + if (parameterType.kind === 154 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -32401,7 +32987,7 @@ var ts; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -32482,7 +33068,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -32543,7 +33129,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -32579,7 +33165,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216 /* ModuleBlock */) { + if (node.body.kind === 217 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -32598,7 +33184,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -32612,7 +33198,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -32624,29 +33210,45 @@ var ts; emitExportMemberAssignments(node.name); } } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8 /* StringLiteral */) { + if (moduleName.kind === 9 /* StringLiteral */) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17 /* CloseParenToken */, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -32661,7 +33263,7 @@ var ts; // ES6 import if (node.importClause) { var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -32674,7 +33276,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -32700,7 +33302,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -32719,7 +33321,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -32770,16 +33372,33 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } } - else if (!(node.flags & 1 /* Export */)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -32808,11 +33427,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -32835,7 +33454,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33466,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33481,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -32883,8 +33498,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 /* FunctionDeclaration */ && - expression.kind !== 211 /* ClassDeclaration */) { + if (expression.kind !== 211 /* FunctionDeclaration */ && + expression.kind !== 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -32898,6 +33513,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33536,9 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" // import x from "mod" where x is referenced // import * as x from "mod" where x is referenced @@ -32930,13 +33546,13 @@ var ts; externalImports.push(node); } break; - case 218 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 219 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -32957,7 +33573,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33599,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - return getLiteralText(moduleName); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -33006,8 +33622,8 @@ var ts; 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 === 225 /* ExportDeclaration */ || - (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 226 /* ExportDeclaration */ || + (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33040,14 +33656,14 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } } if (!hasExportDeclarationWithExportClause) { // we still need to emit exportStar helper - return emitExportStarFunction(undefined); + return emitExportStarFunction(/*localNames*/ undefined); } } var exportedNamesStorageRef = makeUniqueName("exportedNames"); @@ -33072,7 +33688,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225 /* ExportDeclaration */) { + if (externalImport.kind !== 226 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33097,6 +33713,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33722,12 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); @@ -33116,7 +33736,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33127,8 +33747,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33776,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 /* Identifier */ + var name_25 = local.kind === 67 /* Identifier */ ? local : local.name; if (name_25) { @@ -33172,13 +33792,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { + if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33206,21 +33826,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214 /* EnumDeclaration */) { + if (node.kind === 215 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33229,7 +33849,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33858,10 @@ var ts; } return; } - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { - if (shouldHoistVariable(node, false)) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_26 = node.name; - if (name_26.kind === 66 /* Identifier */) { + if (name_26.kind === 67 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } @@ -33253,6 +33873,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -33272,12 +33899,12 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: // function (exports) { // @@ -33322,105 +33949,86 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219 /* ImportDeclaration */: - if (!importNode.importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - // fall-through - case 218 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 /* 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); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 219 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 /* ImportDeclaration */ && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221 /* NamespaceImport */) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments(namedBindings.name); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } 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 225 /* 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("\"]);"); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -33432,17 +34040,33 @@ var ts; 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 225 /* ExportDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 210 /* FunctionDeclaration */: + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: continue; + case 226 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -33467,8 +34091,20 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -33477,8 +34113,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34180,36 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, true); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); increaseIndent(); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); @@ -33579,8 +34219,8 @@ var ts; emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); @@ -33590,9 +34230,10 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); // Emit exportDefault if it exists will happen as part // or normal statement emit. } @@ -33618,7 +34259,7 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; var text = ts.getTextOfNode(node); var firstNonWhitespace = 0; @@ -33631,7 +34272,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -33644,15 +34285,26 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -33666,13 +34318,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2 /* React */: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1 /* Preserve */: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -33681,9 +34333,9 @@ var ts; switch (compilerOptions.jsx) { case 1 /* Preserve */: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2 /* React */: emit(node.expression); @@ -33716,12 +34368,7 @@ var ts; } } } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. @@ -33746,6 +34393,14 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); @@ -33768,57 +34423,76 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2 /* Ambient */) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 225 /* ExportAssignment */: + return true; } } 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 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 224 /* ExportAssignment */: - return false; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(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 !== 189 /* Block */ && + if (node.kind !== 190 /* Block */ && node.parent && - node.parent.kind === 171 /* ArrowFunction */ && + node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -33829,170 +34503,170 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return emitIdentifier(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return emitParameter(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return emitMethod(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessor(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return emitThis(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return emitSuper(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return write("null"); - case 96 /* TrueKeyword */: + case 97 /* TrueKeyword */: return write("true"); - case 81 /* FalseKeyword */: + case 82 /* 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 */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: return emitLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return emitTemplateExpression(node); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return emitTemplateSpan(node); - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 233 /* JsxText */: + case 234 /* JsxText */: return emitJsxText(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return emitJsxExpression(node); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ObjectBindingPattern */: + case 159 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 159 /* ArrayBindingPattern */: + case 160 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return emitBindingElement(node); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 243 /* ShorthandPropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 165 /* CallExpression */: + case 166 /* CallExpression */: return emitCallExpression(node); - case 166 /* NewExpression */: + case 167 /* NewExpression */: return emitNewExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return emit(node.expression); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return emit(node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return emitParenExpression(node); - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return emitDeleteExpression(node); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return emitVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return emitAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return emitBinaryExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return emitConditionalExpression(node); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return emitYieldExpression(node); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return; - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return emitBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitVariableStatement(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: return write(";"); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return emitExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return emitIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return emitDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return emitWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return emitForStatement(node); - case 198 /* ForOfStatement */: - case 197 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 198 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return emitReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return emitWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return emitSwitchStatement(node); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return emitLabelledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return emitThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return emitTryStatement(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return emitCatchClause(node); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return emitClassExpression(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return emitClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMember(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return emitImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34010,6 +34684,11 @@ var ts; } return leadingComments; } + /** + * Removes all but the pinned or triple slash comments. + * @param ranges The array to be filtered + * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed. + */ function filterComments(ranges, onlyPinnedOrTripleSlashComments) { // If we're removing comments, then we want to strip out all but the pinned or // triple slash comments. @@ -34024,7 +34703,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 === 245 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34039,16 +34718,16 @@ 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 === 245 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); } function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { // If the caller only wants pinned or triple slash comments, then always filter @@ -34056,13 +34735,23 @@ var ts; 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); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ 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); + var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitLeadingCommentsOfPosition(pos) { var leadingComments; @@ -34077,7 +34766,7 @@ var ts; 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); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); @@ -34107,7 +34796,7 @@ var ts; if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -34119,6 +34808,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; @@ -34139,6 +34834,261 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// @@ -34149,7 +35099,8 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -34166,6 +35117,53 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + // TODO: use different resolution strategy based on compiler options + return legacyNameResolver(moduleName, containingFile, compilerOptions, host); + } + ts.resolveModuleName = resolveModuleName; + function legacyNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35229,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -34266,7 +35266,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -34277,18 +35277,37 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -34321,6 +35340,71 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -34334,10 +35418,10 @@ var ts; }; } function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken) { var _this = this; @@ -34347,7 +35431,7 @@ var ts; // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -34358,7 +35442,7 @@ var ts; // 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. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -34449,14 +35533,59 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* 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. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -34487,8 +35616,8 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); @@ -34496,22 +35625,22 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, false); + return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); } // We haven't looked for this file, do so now and cache result var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -34522,11 +35651,12 @@ var ts; skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -34542,7 +35672,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -34550,57 +35685,31 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 /* 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. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -34656,28 +35765,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -34685,17 +35794,21 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { @@ -34721,7 +35834,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); @@ -34738,16 +35851,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2 /* ES6 */) { @@ -34879,6 +35998,13 @@ var ts; { name: "out", type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -35088,7 +36214,7 @@ var ts; * @param fileName The path to the config file */ function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -35172,6 +36298,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -35250,7 +36379,7 @@ var ts; } else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); singleLineCommentCount = 0; lastSingleLineCommentEnd = -1; isFirstSingleLineComment = true; @@ -35267,11 +36396,11 @@ var ts; end: end, kind: 2 /* SingleLineCommentTrivia */ }; - addOutliningSpanComments(multipleSingleLineComments, false); + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -35283,34 +36412,34 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189 /* Block */: + case 190 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 194 /* DoStatement */ || - parent_8.kind === 197 /* ForInStatement */ || - parent_8.kind === 198 /* ForOfStatement */ || - parent_8.kind === 196 /* ForStatement */ || - parent_8.kind === 193 /* IfStatement */ || - parent_8.kind === 195 /* WhileStatement */ || - parent_8.kind === 202 /* WithStatement */ || - parent_8.kind === 241 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_7.kind === 195 /* DoStatement */ || + parent_7.kind === 198 /* ForInStatement */ || + parent_7.kind === 199 /* ForOfStatement */ || + parent_7.kind === 197 /* ForStatement */ || + parent_7.kind === 194 /* IfStatement */ || + parent_7.kind === 196 /* WhileStatement */ || + parent_7.kind === 203 /* WithStatement */ || + parent_7.kind === 242 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206 /* TryStatement */) { + if (parent_7.kind === 207 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -35329,25 +36458,25 @@ var ts; break; } // Fallthrough. - case 216 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 217 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 217 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 218 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); + case 162 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -35422,9 +36551,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -35436,8 +36565,8 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); + else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { // Don't know how to add this. @@ -35457,12 +36586,12 @@ var ts; } return true; } - if (expression.kind === 163 /* PropertyAccessExpression */) { + if (expression.kind === 164 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); } return false; } @@ -35470,8 +36599,8 @@ 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 === 133 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } } @@ -35546,17 +36675,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* 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 === 215 /* ModuleDeclaration */); + } while (current.kind === 216 /* ModuleDeclaration */); // fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -35567,21 +36696,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 225 /* ExportDeclaration */: + case 226 /* 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 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35593,7 +36722,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -35602,21 +36731,21 @@ var ts; } } break; - case 160 /* BindingElement */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: childNodes.push(node); break; } @@ -35664,17 +36793,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -35685,12 +36814,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -35750,7 +36879,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +36887,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* CallSignature */: + case 145 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: var variableDeclarationNode; var name_29; - if (node.kind === 160 /* BindingElement */) { + if (node.kind === 161 /* BindingElement */) { name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -35806,13 +36935,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141 /* Constructor */: + case 142 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -35842,29 +36971,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: return createSourceFileItem(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return createClassItem(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return createEnumItem(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return createModuleItem(node); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 8 /* StringLiteral */) { + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { return getTextOfNode(moduleDeclaration.name); } // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -35876,7 +37005,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 === 189 /* Block */) { + if (node.body && node.body.kind === 190 /* 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)); } @@ -35897,7 +37026,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* 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 @@ -35921,7 +37050,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -35930,13 +37059,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215 /* ModuleDeclaration */) { + while (node.body.kind === 216 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 /* SourceFile */ + return node.kind === 246 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -36039,12 +37168,12 @@ var ts; if (chunk.text.length === candidate.length) { // a) Check if the part matches the candidate entirely, in an case insensitive or // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); } else { // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -36060,9 +37189,9 @@ var ts; var wordSpans = getWordSpans(candidate); for (var _i = 0; _i < wordSpans.length; _i++) { var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, true)) { + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); } } } @@ -36072,20 +37201,20 @@ var ts; // candidate in a case *sensitive* manner. If so, return that there was a substring // match. if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); } } if (!isLowercase) { // e) If the part was not entirely lowercase, then attempt a camel cased match as well. if (chunk.characterSpans.length > 0) { var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); } } } @@ -36098,7 +37227,7 @@ var ts; // (Pattern: fogbar, Candidate: quuxfogbarFogBar). if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); } } } @@ -36122,7 +37251,7 @@ var ts; // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); if (match) { return [match]; } @@ -36168,7 +37297,7 @@ var ts; for (var _i = 0; _i < subWordTextChunks.length; _i++) { var subWordTextChunk = subWordTextChunks[_i]; // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, true); + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { return undefined; } @@ -36434,11 +37563,11 @@ var ts; }; } /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); + return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); + return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; function breakIntoSpans(identifier, word) { @@ -36731,15 +37860,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 /* Identifier */ + var name = expression.kind === 67 /* Identifier */ ? expression - : expression.kind === 163 /* PropertyAccessExpression */ + : expression.kind === 164 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -36772,7 +37901,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { + if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -36788,8 +37917,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 24 /* LessThanToken */ || - node.kind === 16 /* OpenParenToken */) { + if (node.kind === 25 /* LessThanToken */ || + node.kind === 17 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -36825,27 +37954,27 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* 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); + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -36873,7 +38002,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38021,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -36923,7 +38052,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 10 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -36945,7 +38074,7 @@ var ts; // The applicable span is from the first bar to the second bar (inclusive, // but not including parentheses) var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getApplicableSpanForTaggedTemplate(taggedTemplate) { @@ -36961,16 +38090,16 @@ 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 === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } } return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -37021,7 +38150,7 @@ var ts; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; @@ -37030,10 +38159,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -37044,10 +38173,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -37057,7 +38186,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -37081,12 +38210,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -37171,40 +38299,40 @@ var ts; return false; } switch (n.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 158 /* ObjectBindingPattern */: - case 152 /* TypeLiteral */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 217 /* CaseBlock */: - return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 241 /* CatchClause */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 159 /* ObjectBindingPattern */: + case 153 /* TypeLiteral */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 218 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 242 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 166 /* NewExpression */: + case 167 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: - case 157 /* ParenthesizedType */: - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: + case 158 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -37213,64 +38341,64 @@ 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 215 /* ModuleDeclaration */: + return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); + case 216 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 193 /* IfStatement */: + case 194 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 161 /* ArrayLiteralExpression */: - case 159 /* ArrayBindingPattern */: - case 164 /* ElementAccessExpression */: - case 133 /* ComputedPropertyName */: - case 154 /* TupleType */: - return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 146 /* IndexSignature */: + case 162 /* ArrayLiteralExpression */: + case 160 /* ArrayBindingPattern */: + case 165 /* ElementAccessExpression */: + case 134 /* ComputedPropertyName */: + case 155 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 147 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 173 /* TypeOfExpression */: - case 172 /* DeleteExpression */: - case 174 /* VoidExpression */: - case 181 /* YieldExpression */: - case 182 /* SpreadElementExpression */: + case 174 /* TypeOfExpression */: + case 173 /* DeleteExpression */: + case 175 /* VoidExpression */: + case 182 /* YieldExpression */: + case 183 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -37288,7 +38416,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -37326,7 +38454,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 === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -37351,12 +38479,12 @@ var ts; ts.getTouchingPropertyName = getTouchingPropertyName; /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, true, undefined); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ @@ -37436,7 +38564,7 @@ var ts; return n; } var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } function find(n) { @@ -37450,7 +38578,7 @@ var ts; if (position <= child.end) { if (child.getStart(sourceFile) >= position) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, i); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); return candidate && findRightmostToken(candidate); } else { @@ -37460,13 +38588,13 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 246 /* 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. // Namely we are skipping the check: 'position < node.end' if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } } @@ -37480,6 +38608,54 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. // Note, that getWidth() does not take trivia into account. @@ -37506,32 +38682,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { + if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 /* Identifier */ || ts.isKeyword(kind); + return kind === 67 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 /* StringLiteral */ || kind === 7 /* NumericLiteral */ || isWord(kind); + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); } function isComment(kind) { return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -37541,9 +38717,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: return true; } return false; @@ -37571,7 +38747,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -37706,6 +38882,14 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -37750,7 +38934,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -37778,7 +38962,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -37848,25 +39032,25 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28 /* GreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanToken */: + case 29 /* GreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanToken */: return true; } } return false; } function shouldRescanSlashToken(container) { - return container.kind === 9 /* RegularExpressionLiteral */; + return container.kind === 10 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 12 /* TemplateMiddle */ || - container.kind === 13 /* TemplateTail */; + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; + return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -37902,7 +39086,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -37912,7 +39096,7 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 15 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } @@ -38041,8 +39225,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -38233,112 +39417,112 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for indexer and dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space before and after indexer + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* 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([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* 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 */)); // TypeScript-specific higher priority rules // 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(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* 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([122 /* ModuleKeyword */, 124 /* 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([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* 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([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* 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([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* 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([81 /* ExtendsKeyword */, 104 /* 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 */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* 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([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* 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([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38378,6 +39562,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39573,8 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally @@ -38398,35 +39583,41 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function //TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenParenToken */, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -38441,38 +39632,38 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 196 /* ForStatement */; + return context.contextNode.kind === 197 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 186 /* AsExpression */: - case 147 /* TypePredicate */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 187 /* AsExpression */: + case 148 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 160 /* BindingElement */: + case 161 /* BindingElement */: // equals in type X = ... - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: // equal in p = 0; - case 135 /* Parameter */: - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; + case 136 /* Parameter */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 197 /* ForInStatement */: - return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; + case 198 /* ForInStatement */: + return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 198 /* ForOfStatement */: - return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; + case 199 /* ForOfStatement */: + return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; } return false; }; @@ -38480,7 +39671,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179 /* ConditionalExpression */; + return context.contextNode.kind === 180 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -38524,98 +39715,98 @@ var ts; return true; } switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 162 /* ObjectLiteralExpression */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 163 /* ObjectLiteralExpression */: + case 217 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 144 /* CallSignature */: - case 170 /* FunctionExpression */: - case 141 /* Constructor */: - case 171 /* ArrowFunction */: + case 145 /* CallSignature */: + case 171 /* FunctionExpression */: + case 142 /* Constructor */: + case 172 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; + return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 215 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 216 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211 /* ClassDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 189 /* Block */: - case 241 /* CatchClause */: - case 216 /* ModuleBlock */: - case 203 /* SwitchStatement */: + case 212 /* ClassDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 190 /* Block */: + case 242 /* CatchClause */: + case 217 /* ModuleBlock */: + case 204 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193 /* IfStatement */: - case 203 /* SwitchStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 206 /* TryStatement */: - case 194 /* DoStatement */: - case 202 /* WithStatement */: + case 194 /* IfStatement */: + case 204 /* SwitchStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 207 /* TryStatement */: + case 195 /* DoStatement */: + case 203 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 241 /* CatchClause */: + case 242 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162 /* ObjectLiteralExpression */; + return context.contextNode.kind === 163 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165 /* CallExpression */; + return context.contextNode.kind === 166 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166 /* NewExpression */; + return context.contextNode.kind === 167 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23 /* CommaToken */; + return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -38633,52 +39824,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136 /* Decorator */; + return node.kind === 137 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 210 /* 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 === 215 /* ModuleDeclaration */; + return context.contextNode.kind === 216 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 148 /* TypeReference */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 149 /* TypeReference */: + case 169 /* TypeAssertionExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 186 /* ExpressionWithTypeArguments */: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; + return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -38702,7 +39899,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 /* LastToken */ + 1; + this.mapRowLength = 132 /* 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); @@ -38897,7 +40094,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { result.push(token); } return result; @@ -38939,17 +40136,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -39027,6 +40224,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -39085,11 +40292,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -39153,17 +40360,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 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 245 /* SourceFile */: - case 189 /* Block */: - case 216 /* ModuleBlock */: + return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 246 /* SourceFile */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -39336,9 +40543,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 245 /* SourceFile */ || - parent.kind === 238 /* CaseClause */ || - parent.kind === 239 /* DefaultClause */) { + parent.kind === 246 /* SourceFile */ || + parent.kind === 239 /* CaseClause */ || + parent.kind === 240 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -39374,19 +40581,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; - case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; - case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; - case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; - case 142 /* GetAccessor */: return 120 /* GetKeyword */; - case 143 /* SetAccessor */: return 126 /* SetKeyword */; - case 140 /* MethodDeclaration */: + case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; + case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; + case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; + case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; + case 143 /* GetAccessor */: return 121 /* GetKeyword */; + case 144 /* SetAccessor */: return 127 /* SetKeyword */; + case 141 /* MethodDeclaration */: if (node.asteriskToken) { - return 36 /* AsteriskToken */; + return 37 /* AsteriskToken */; } // fall-through - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: return node.name.kind; } } @@ -39398,8 +40605,8 @@ var ts; // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: return indentation + delta; } return indentation; @@ -39413,15 +40620,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 14 /* OpenBraceToken */: - case 15 /* CloseBraceToken */: - case 18 /* OpenBracketToken */: - case 19 /* CloseBracketToken */: - case 16 /* OpenParenToken */: - case 17 /* CloseParenToken */: - case 77 /* ElseKeyword */: - case 101 /* WhileKeyword */: - case 53 /* AtToken */: + case 15 /* OpenBraceToken */: + case 16 /* CloseBraceToken */: + case 19 /* OpenBracketToken */: + case 20 /* CloseBracketToken */: + case 17 /* OpenParenToken */: + case 18 /* CloseParenToken */: + case 78 /* ElseKeyword */: + case 102 /* WhileKeyword */: + case 54 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -39468,7 +40675,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -39521,7 +40728,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -39556,7 +40763,7 @@ var ts; var inheritedIndentation = -1 /* Unknown */; for (var _i = 0; _i < nodes.length; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { if (formattingScanner.isOnToken()) { @@ -39614,13 +40821,13 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2 /* SingleLineCommentTrivia */: if (indentNextTokenOrTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } break; @@ -39683,7 +40890,7 @@ var ts; // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(false); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { @@ -39692,7 +40899,7 @@ var ts; // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(true); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -39732,7 +40939,7 @@ var ts; if (startLine === endLine) { if (!firstLineIsIndented) { // treat as single line comment - insertIndentation(commentRange.pos, indentation, false); + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); } return; } @@ -39844,49 +41051,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141 /* Constructor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 172 /* ArrowFunction */: if (node.typeParameters === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.parameters === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.arguments === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16 /* OpenParenToken */: - return 17 /* CloseParenToken */; - case 24 /* LessThanToken */: - return 26 /* GreaterThanToken */; + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -39963,17 +41170,17 @@ var ts; return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 8 /* StringLiteral */ || - precedingToken.kind === 9 /* RegularExpressionLiteral */ || - precedingToken.kind === 10 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 11 /* TemplateHead */ || - precedingToken.kind === 12 /* TemplateMiddle */ || - precedingToken.kind === 13 /* TemplateTail */; + var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || + precedingToken.kind === 10 /* RegularExpressionLiteral */ || + precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || + precedingToken.kind === 12 /* TemplateHead */ || + precedingToken.kind === 13 /* TemplateMiddle */ || + precedingToken.kind === 14 /* TemplateTail */; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* 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 */) { @@ -40013,12 +41220,12 @@ var ts; // no parent was found - return 0 to be indented on the level of SourceFile return 0; } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { @@ -40092,7 +41299,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 === 245 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -40103,11 +41310,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14 /* OpenBraceToken */) { + if (nextToken.kind === 15 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 15 /* CloseBraceToken */) { + else if (nextToken.kind === 16 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -40125,8 +41332,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); + if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -40137,23 +41344,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return node.parent.properties; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return node.parent.elements; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: { + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -40164,8 +41371,8 @@ var ts; } break; } - case 166 /* NewExpression */: - case 165 /* CallExpression */: { + case 167 /* NewExpression */: + case 166 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -40192,11 +41399,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 17 /* CloseParenToken */) { + if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 165 /* CallExpression */ || - node.parent.kind === 166 /* NewExpression */) && + if (node.parent && (node.parent.kind === 166 /* CallExpression */ || + node.parent.kind === 167 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -40214,10 +41421,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: node = node.expression; break; default: @@ -40234,7 +41441,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23 /* CommaToken */) { + if (list[i].kind === 24 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -40282,28 +41489,30 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 161 /* ArrayLiteralExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 162 /* ObjectLiteralExpression */: - case 152 /* TypeLiteral */: - case 154 /* TupleType */: - case 217 /* CaseBlock */: - case 239 /* DefaultClause */: - case 238 /* CaseClause */: - case 169 /* ParenthesizedExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 190 /* VariableStatement */: - case 208 /* VariableDeclaration */: - case 224 /* ExportAssignment */: - case 201 /* ReturnStatement */: - case 179 /* ConditionalExpression */: - case 159 /* ArrayBindingPattern */: - case 158 /* ObjectBindingPattern */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 162 /* ArrayLiteralExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 163 /* ObjectLiteralExpression */: + case 153 /* TypeLiteral */: + case 155 /* TupleType */: + case 218 /* CaseBlock */: + case 240 /* DefaultClause */: + case 239 /* CaseClause */: + case 170 /* ParenthesizedExpression */: + case 164 /* PropertyAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 191 /* VariableStatement */: + case 209 /* VariableDeclaration */: + case 225 /* ExportAssignment */: + case 202 /* ReturnStatement */: + case 180 /* ConditionalExpression */: + case 160 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 231 /* JsxElement */: return true; } return false; @@ -40313,22 +41522,22 @@ var ts; return true; } switch (parent) { - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - return child !== 189 /* Block */; + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,7 +41589,7 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); @@ -40431,7 +41640,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -40450,7 +41659,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132 /* FirstNode */) { + if (this.kind >= 133 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -40492,24 +41701,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -40550,15 +41755,15 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration, indexOfDeclaration) { // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times + // In case of union property there might be same declaration multiple times // which only varies in type parameter // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming + // The property length will have two declarations of property length coming // from Array - Array and Array 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 === 135 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -40567,15 +41772,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { + if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { + while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -40588,7 +41793,7 @@ var ts; return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { return { pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator + end: jsDocComment.end - "*/".length // Trim off comment end indicator }; }); } @@ -40690,7 +41895,7 @@ var ts; if (isParamTag(pos, end, sourceFile)) { var blankLineCount = 0; var recordedParamTag = false; - // Consume leading spaces + // Consume leading spaces pos = consumeWhiteSpaces(pos + paramTag.length); if (pos >= end) { break; @@ -40740,7 +41945,7 @@ var ts; var firstLineParamHelpStringPos = pos; while (pos < end) { var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line + // at line break, set this comment line text and go to next line if (ts.isLineBreak(ch)) { if (paramHelpString) { pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); @@ -40793,7 +41998,7 @@ var ts; if (paramHelpStringMargin === undefined) { paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; } - // Now consume white spaces max + // Now consume white spaces max var startOfLinePos = pos; pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); if (pos >= end) { @@ -40843,6 +42048,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -40914,9 +42124,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133 /* ComputedPropertyName */) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -40926,9 +42136,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -40936,9 +42146,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -40958,60 +42168,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 152 /* TypeLiteral */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 153 /* TypeLiteral */: addDeclaration(node); // fall through - case 141 /* Constructor */: - case 190 /* VariableStatement */: - case 209 /* VariableDeclarationList */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 216 /* ModuleBlock */: + case 142 /* Constructor */: + case 191 /* VariableStatement */: + case 210 /* VariableDeclarationList */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 217 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135 /* Parameter */: + case 136 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: addDeclaration(node); break; - case 225 /* ExportDeclaration */: + case 226 /* 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 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -41023,7 +42233,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -41227,16 +42437,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 170 /* FunctionExpression */) { + if (declaration.kind === 171 /* FunctionExpression */) { return true; } - if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { + if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { + if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { return false; } } @@ -41253,8 +42463,8 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { @@ -41331,7 +42541,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -41356,52 +42566,76 @@ var ts; /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used bu this function are: + * Extra compiler options that will unconditionally be used by this function are: * - isolatedModules = true * - allowNonTsExtensions = true * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, + // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. options.noLib = true; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; // Parse - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); // Output var outputText; + var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -41415,7 +42649,7 @@ var ts; ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; ts.disableIncrementalParsing = false; function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then + // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. if (textChangeRange) { if (version !== sourceFile.version) { @@ -41461,7 +42695,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames) { @@ -41469,13 +42703,14 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -41506,18 +42741,18 @@ var ts; return JSON.stringify(bucketInfoArray, null, 2); } function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); } function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, true); + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -41526,7 +42761,7 @@ var ts; bucket.set(fileName, entry); } else { - // We have an entry for this file. However, it may be for a different version of + // We have an entry for this file. However, it may be for a different version of // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { @@ -41565,6 +42800,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -41580,6 +42816,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41603,31 +42845,42 @@ var ts; // export * from "mod" // export {a as b} from "mod" while (token !== 1 /* EndOfFileToken */) { - if (token === 86 /* ImportKeyword */) { + if (token === 120 /* DeclareKeyword */) { + // declare module "mod" token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 123 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { // import "mod"; recordModuleName(); continue; } else { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import d from "mod"; recordModuleName(); continue; } } - else if (token === 54 /* EqualsToken */) { + else if (token === 55 /* EqualsToken */) { token = scanner.scan(); - if (token === 124 /* RequireKeyword */) { + if (token === 125 /* RequireKeyword */) { token = scanner.scan(); - if (token === 16 /* OpenParenToken */) { + if (token === 17 /* OpenParenToken */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import i = require("mod"); recordModuleName(); continue; @@ -41635,7 +42888,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +42897,17 @@ var ts; continue; } } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -41662,15 +42915,15 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { token = scanner.scan(); - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -41681,19 +42934,19 @@ var ts; } } } - else if (token === 79 /* ExportKeyword */) { + else if (token === 80 /* ExportKeyword */) { token = scanner.scan(); - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -41701,11 +42954,11 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export * from "mod" recordModuleName(); } @@ -41720,13 +42973,13 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -41734,13 +42987,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 /* Identifier */ && - (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && + return node.kind === 67 /* Identifier */ && + (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 /* Identifier */ && - node.parent.kind === 204 /* LabeledStatement */ && + return node.kind === 67 /* Identifier */ && + node.parent.kind === 205 /* LabeledStatement */ && node.parent.label === node; } /** @@ -41748,7 +43001,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -41759,56 +43012,56 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** 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 === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 215 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 216 /* ModuleDeclaration */: return node.parent.name === node; - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -41860,7 +43113,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { + for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -41875,17 +43128,17 @@ var ts; return undefined; } switch (node.kind) { - case 245 /* SourceFile */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: return node; } } @@ -41893,38 +43146,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 208 /* VariableDeclaration */: + case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 209 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 244 /* EnumMember */: return ScriptElementKind.variableElement; - case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 220 /* ImportClause */: - case 227 /* ExportSpecifier */: - case 221 /* NamespaceImport */: + case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 245 /* EnumMember */: return ScriptElementKind.variableElement; + case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 228 /* ExportSpecifier */: + case 222 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -41995,26 +43248,44 @@ var ts; if (programUpToDate()) { return; } - // IMPORTANT - It is critical from this moment onward that we do not check + // IMPORTANT - It is critical from this moment onward that we do not check // cancellation tokens. We are about to mutate source files from a previous program // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of + // the program points to old source files that have been invalidated because of // incremental parsing. var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); // Now create a new compiler - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); - // Release any files we have acquired in the old program but are + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + // Release any files we have acquired in the old program but are // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); @@ -42030,7 +43301,7 @@ var ts; // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent + // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. program.getTypeChecker(); return; @@ -42050,7 +43321,7 @@ var ts; // Check if the old program had this file already var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to + // We already had a source file for this file name. Go to the registry to // ensure that we get the right up to date version of it. We need this to // address the following 'race'. Specifically, say we have the following: // @@ -42061,15 +43332,15 @@ var ts; // LS2 // // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will // have version 1. And *importantly* this source file will be *corrupt*. // The act of creating version 2 of the file irrevocably damages the version // 1 file. // // So, later when we call into LS1, we need to make sure that it doesn't use // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the + // either version 1, version 2 (or some other version) depending on what the // host says should be used. return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } @@ -42128,7 +43399,7 @@ var ts; synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a + // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. if (ts.isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); @@ -42152,44 +43423,44 @@ var ts; return false; } switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 103 /* ImplementsKeyword */) { + if (heritageClause.token === 104 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -42197,20 +43468,20 @@ var ts; return true; } break; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -42218,7 +43489,7 @@ var ts; return true; } break; - case 135 /* Parameter */: + case 136 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -42234,17 +43505,17 @@ var ts; return true; } break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168 /* TypeAssertionExpression */: + case 169 /* 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 136 /* Decorator */: + case 137 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -42270,18 +43541,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 119 /* DeclareKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 120 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 110 /* StaticKeyword */: - case 79 /* ExportKeyword */: - case 71 /* ConstKeyword */: - case 74 /* DefaultKeyword */: - case 112 /* AbstractKeyword */: + case 111 /* StaticKeyword */: + case 80 /* ExportKeyword */: + case 72 /* ConstKeyword */: + case 75 /* DefaultKeyword */: + case 113 /* AbstractKeyword */: } } } @@ -42380,13 +43651,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20 /* DotToken */) { - if (parent_10.kind === 163 /* PropertyAccessExpression */) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 164 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132 /* QualifiedName */) { + else if (parent_9.kind === 133 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -42396,7 +43667,7 @@ var ts; return undefined; } } - else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { isRightOfOpenTag = true; location = contextToken; } @@ -42433,7 +43704,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { + if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -42462,7 +43733,7 @@ var ts; } } if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that + // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part @@ -42489,7 +43760,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -42510,10 +43781,10 @@ var ts; // aggregating completion candidates. This is achieved in 'getScopeNode' // by finding the first node that encompasses a position, accounting for whether a node // is "complete" to decide whether a position belongs to the node. - // + // // However, at the end of an identifier, we are interested in the scope of the identifier // itself, but fall outside of the identifier. For instance: - // + // // xyz => x$ // // the cursor is outside of both the 'x' and the arrow function 'xyz => x', @@ -42563,41 +43834,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 165 /* CallExpression */ // func( a, | - || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 166 /* NewExpression */ // new C(a, | - || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| - case 16 /* OpenParenToken */: - return containingNodeKind === 165 /* CallExpression */ // func( | - || containingNodeKind === 141 /* Constructor */ // constructor( | - || containingNodeKind === 166 /* NewExpression */ // new C(a| - || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 18 /* OpenBracketToken */: - return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 122 /* ModuleKeyword */: // module | - case 123 /* NamespaceKeyword */: + case 24 /* CommaToken */: + return containingNodeKind === 166 /* CallExpression */ // func( a, | + || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 167 /* NewExpression */ // new C(a, | + || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 166 /* CallExpression */ // func( | + || containingNodeKind === 142 /* Constructor */ // constructor( | + || containingNodeKind === 167 /* NewExpression */ // new C(a| + || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 123 /* ModuleKeyword */: // module | + case 124 /* NamespaceKeyword */: return true; - case 20 /* DotToken */: - return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| - case 14 /* OpenBraceToken */: - return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | - case 54 /* EqualsToken */: - return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 178 /* BinaryExpression */; // x = a| - case 11 /* TemplateHead */: - return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| - case 12 /* TemplateMiddle */: - return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | + case 21 /* DotToken */: + return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | + case 55 /* EqualsToken */: + return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 179 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -42610,8 +43881,8 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 /* StringLiteral */ - || contextToken.kind === 9 /* RegularExpressionLiteral */ + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -42624,7 +43895,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +43911,29 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -42682,9 +43964,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? - 219 /* ImportDeclaration */ : - 225 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? + 220 /* ImportDeclaration */ : + 226 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -42707,11 +43989,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // let x = { | - case 23 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { - return parent_11; + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + return parent_10; } break; } @@ -42725,11 +44007,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // import { | - case 23 /* CommaToken */: + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return contextToken.parent; } } @@ -42738,24 +44020,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25 /* LessThanSlashToken */: - case 37 /* SlashToken */: - case 66 /* Identifier */: - if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { - return parent_12; + case 26 /* LessThanSlashToken */: + case 38 /* SlashToken */: + case 67 /* Identifier */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + return parent_11; } break; - case 15 /* CloseBraceToken */: - // The context token is the closing } of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - if (parent_12 && - parent_12.kind === 237 /* JsxExpression */ && - parent_12.parent && - parent_12.parent.kind === 235 /* JsxAttribute */) { - return parent_12.parent.parent; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 238 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 236 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + return parent_11.parent; } break; } @@ -42764,16 +44056,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return true; } return false; @@ -42784,65 +44076,65 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 208 /* VariableDeclaration */ || - containingNodeKind === 209 /* VariableDeclarationList */ || - containingNodeKind === 190 /* VariableStatement */ || - containingNodeKind === 214 /* EnumDeclaration */ || + case 24 /* CommaToken */: + return containingNodeKind === 209 /* VariableDeclaration */ || + containingNodeKind === 210 /* VariableDeclarationList */ || + containingNodeKind === 191 /* VariableStatement */ || + containingNodeKind === 215 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| - case 20 /* DotToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| - case 52 /* ColonToken */: - return containingNodeKind === 160 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 241 /* CatchClause */ || + containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 211 /* FunctionDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */; // var [x, y| + case 21 /* DotToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| + case 53 /* ColonToken */: + return containingNodeKind === 161 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 242 /* CatchClause */ || isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 214 /* EnumDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* TypeLiteral */; // let x : { | - case 22 /* SemicolonToken */: - return containingNodeKind === 137 /* PropertySignature */ && + case 15 /* OpenBraceToken */: + return containingNodeKind === 215 /* EnumDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 153 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 138 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 211 /* FunctionDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || isFunction(containingNodeKind); - case 110 /* StaticKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 135 /* Parameter */ || + case 111 /* StaticKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 136 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 135 /* Parameter */; - case 113 /* AsKeyword */: - containingNodeKind === 223 /* ImportSpecifier */ || - containingNodeKind === 227 /* ExportSpecifier */ || - containingNodeKind === 221 /* NamespaceImport */; - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 104 /* InterfaceKeyword */: - case 84 /* FunctionKeyword */: - case 99 /* VarKeyword */: - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - case 86 /* ImportKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 111 /* YieldKeyword */: - case 129 /* TypeKeyword */: + contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 136 /* Parameter */; + case 114 /* AsKeyword */: + containingNodeKind === 224 /* ImportSpecifier */ || + containingNodeKind === 228 /* ExportSpecifier */ || + containingNodeKind === 222 /* NamespaceImport */; + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 105 /* InterfaceKeyword */: + case 85 /* FunctionKeyword */: + case 100 /* VarKeyword */: + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + case 87 /* ImportKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 112 /* YieldKeyword */: + case 130 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -42861,7 +44153,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7 /* NumericLiteral */) { + if (contextToken.kind === 8 /* NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -42906,9 +44198,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 242 /* PropertyAssignment */ && - m.kind !== 243 /* ShorthandPropertyAssignment */ && - m.kind !== 160 /* BindingElement */) { + if (m.kind !== 243 /* PropertyAssignment */ && + m.kind !== 244 /* ShorthandPropertyAssignment */ && + m.kind !== 161 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -42916,7 +44208,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 160 /* BindingElement */ && m.propertyName) { + if (m.kind === 161 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -42943,7 +44235,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235 /* JsxAttribute */) { + if (attr.kind === 236 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -42983,7 +44275,7 @@ var ts; for (var name_32 in nameTable) { if (!allNames[name_32]) { allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); if (displayName) { var entry = { name: displayName, @@ -42999,17 +44291,17 @@ var ts; return entries; } function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); if (!displayName) { return undefined; } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what + // that a suggestion for a value is an interface. We COULD also just do what // 'getSymbolModifiers' does, which is to use the first declaration. // Use a 'sortText' of 0' so that all symbol completion entries come before any other // entries (like JavaScript identifier entries). @@ -43049,10 +44341,10 @@ var ts; var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); if (symbol) { var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { @@ -43081,7 +44373,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -43145,7 +44437,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - // If this was union of all methods, + // If this was union of all methods, //make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { @@ -43183,7 +44475,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 164 /* 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)) { @@ -43192,7 +44484,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { + if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -43205,10 +44497,10 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -43222,7 +44514,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -43238,14 +44530,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -43257,24 +44549,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { + (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141 /* Constructor */) { + if (functionDeclaration.kind === 142 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -43283,7 +44575,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -43291,7 +44583,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -43299,48 +44591,48 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87 /* InKeyword */)); + displayParts.push(ts.keywordPart(88 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -43349,13 +44641,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -43364,11 +44656,11 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244 /* EnumMember */) { + if (declaration.kind === 245 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -43376,26 +44668,26 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218 /* ImportEqualsDeclaration */) { + if (declaration.kind === 219 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -43412,7 +44704,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -43450,7 +44742,7 @@ var ts; } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -43471,9 +44763,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); return; } } @@ -43481,12 +44773,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(34 /* PlusToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(35 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -43512,11 +44804,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -43560,7 +44852,7 @@ var ts; 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. + // Just add all the declarations. ts.forEach(declarations, function (declaration) { result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); @@ -43569,18 +44861,18 @@ var ts; 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 === 118 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 212 /* ClassDeclaration */); + return tryAddSignature(classDeclaration.members, /*selectConstructors*/ 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 tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); } return false; } @@ -43588,8 +44880,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141 /* Constructor */) || - (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 142 /* Constructor */) || + (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -43618,7 +44910,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } /// Triple slash reference comments var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); @@ -43649,16 +44941,16 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 66 /* Identifier */ && node.parent === declaration) { + if (node.kind === 67 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // 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 === 243 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -43692,7 +44984,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -43706,7 +44998,7 @@ var ts; var results = getOccurrencesAtPositionCore(fileName, position); if (results) { var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So + // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); } @@ -43732,12 +45024,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 94 /* ThisKeyword */ || - node.kind === 92 /* SuperKeyword */ || + if (node.kind === 67 /* Identifier */ || + node.kind === 95 /* ThisKeyword */ || + node.kind === 93 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -43785,77 +45077,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85 /* IfKeyword */: - case 77 /* ElseKeyword */: - if (hasKind(node.parent, 193 /* IfStatement */)) { + case 86 /* IfKeyword */: + case 78 /* ElseKeyword */: + if (hasKind(node.parent, 194 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 91 /* ReturnKeyword */: - if (hasKind(node.parent, 201 /* ReturnStatement */)) { + case 92 /* ReturnKeyword */: + if (hasKind(node.parent, 202 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 95 /* ThrowKeyword */: - if (hasKind(node.parent, 205 /* ThrowStatement */)) { + case 96 /* ThrowKeyword */: + if (hasKind(node.parent, 206 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 69 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { + case 70 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97 /* TryKeyword */: - case 82 /* FinallyKeyword */: - if (hasKind(parent(node), 206 /* TryStatement */)) { + case 98 /* TryKeyword */: + case 83 /* FinallyKeyword */: + if (hasKind(parent(node), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93 /* SwitchKeyword */: - if (hasKind(node.parent, 203 /* SwitchStatement */)) { + case 94 /* SwitchKeyword */: + if (hasKind(node.parent, 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68 /* CaseKeyword */: - case 74 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { + case 69 /* CaseKeyword */: + case 75 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67 /* BreakKeyword */: - case 72 /* ContinueKeyword */: - if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68 /* BreakKeyword */: + case 73 /* ContinueKeyword */: + if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83 /* ForKeyword */: - if (hasKind(node.parent, 196 /* ForStatement */) || - hasKind(node.parent, 197 /* ForInStatement */) || - hasKind(node.parent, 198 /* ForOfStatement */)) { + case 84 /* ForKeyword */: + if (hasKind(node.parent, 197 /* ForStatement */) || + hasKind(node.parent, 198 /* ForInStatement */) || + hasKind(node.parent, 199 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101 /* WhileKeyword */: - case 76 /* DoKeyword */: - if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { + case 102 /* WhileKeyword */: + case 77 /* DoKeyword */: + if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118 /* ConstructorKeyword */: - if (hasKind(node.parent, 141 /* Constructor */)) { + case 119 /* ConstructorKeyword */: + if (hasKind(node.parent, 142 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -43871,10 +45163,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* ThrowStatement */) { + if (node.kind === 206 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 206 /* TryStatement */) { + else if (node.kind === 207 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -43902,19 +45194,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + return parent_12; } // 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_13.kind === 206 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_12.kind === 207 /* TryStatement */) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -43923,7 +45215,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { + if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -43939,16 +45231,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203 /* SwitchStatement */: - if (statement.kind === 199 /* ContinueStatement */) { + case 204 /* SwitchStatement */: + if (statement.kind === 200 /* ContinueStatement */) { continue; } // Fall through. - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -43967,24 +45259,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 /* ClassDeclaration */ || - container.kind === 183 /* ClassExpression */ || - (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { + if (!(container.kind === 212 /* ClassDeclaration */ || + container.kind === 184 /* ClassExpression */ || + (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { return undefined; } } - else if (modifier === 110 /* StaticKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { + else if (modifier === 111 /* StaticKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { return undefined; } } - else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { - if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { + else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { + if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { return undefined; } } - else if (modifier === 112 /* AbstractKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + else if (modifier === 113 /* AbstractKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { return undefined; } } @@ -43996,8 +45288,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216 /* ModuleBlock */: - case 245 /* SourceFile */: + case 217 /* ModuleBlock */: + case 246 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -44006,17 +45298,17 @@ var ts; nodes = container.statements; } break; - case 141 /* Constructor */: + case 142 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -44037,19 +45329,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109 /* PublicKeyword */: + case 110 /* PublicKeyword */: return 16 /* Public */; - case 107 /* PrivateKeyword */: + case 108 /* PrivateKeyword */: return 32 /* Private */; - case 108 /* ProtectedKeyword */: + case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: return 128 /* Static */; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -44069,13 +45361,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* 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, 120 /* GetKeyword */, 126 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); } } } @@ -44084,19 +45376,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 194 /* DoStatement */) { + if (loopNode.kind === 195 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { break; } } @@ -44105,22 +45397,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -44128,14 +45420,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); } }); }); @@ -44143,13 +45435,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -44160,13 +45452,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -44174,36 +45466,36 @@ 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, 189 /* Block */))) { + if (!(func && hasKind(func.body, 190 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -44212,7 +45504,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -44279,11 +45571,11 @@ var ts; return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } @@ -44294,7 +45586,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 /* Identifier */ && + if (node.kind !== 67 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -44302,7 +45594,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -44320,10 +45612,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94 /* ThisKeyword */) { + if (node.kind === 95 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92 /* SuperKeyword */) { + if (node.kind === 93 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -44383,7 +45675,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; + return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -44410,14 +45702,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -44443,7 +45735,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 246 /* 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; @@ -44471,12 +45763,12 @@ var ts; // If we are past the end, stop looking if (position > end) break; - // We found a match. Make sure it's not part of a larger word (i.e. the char + // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { - // Found a real match. Keep searching. + // Found a real match. Keep searching. positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -44514,16 +45806,16 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return node.getWidth() === searchSymbolName.length; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { // For string literals we have two additional chars for the quotes return node.getWidth() === searchSymbolName.length + 2; } break; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -44547,11 +45839,11 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a + // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like @@ -44600,44 +45892,29 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 /* StringLiteral */ && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // Then we want to make sure that it wasn't in a "///<" directive comment - // We don't want to unintentionally update a file name. - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); if (!searchSpaceNode) { return undefined; } // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -44650,10 +45927,10 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92 /* SuperKeyword */) { + if (!node || node.kind !== 93 /* SuperKeyword */) { return; } - var container = ts.getSuperContainer(node, false); + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. @@ -44665,31 +45942,31 @@ var ts; return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 171 /* 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. @@ -44698,7 +45975,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245 /* SourceFile */) { + if (searchSpaceNode.kind === 246 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -44724,32 +46001,32 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94 /* ThisKeyword */) { + if (!node || node.kind !== 95 /* ThisKeyword */) { return; } - var container = ts.getThisContainer(node, false); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211 /* ClassDeclaration */: + case 212 /* 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 245 /* SourceFile */: - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + case 246 /* SourceFile */: + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -44803,11 +46080,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 === 211 /* ClassDeclaration */) { + if (declaration.kind === 212 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212 /* InterfaceDeclaration */) { + else if (declaration.kind === 213 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -44839,7 +46116,7 @@ var ts; return aliasedSymbol; } } - // If the reference location is in an object literal, try to get the contextual type for the + // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol if (isNameOfPropertyAssignment(referenceLocation)) { @@ -44854,7 +46131,7 @@ var ts; if (searchSymbols.indexOf(rootSymbol) >= 0) { return rootSymbol; } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; @@ -44930,7 +46207,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { start += 1; end -= 1; } @@ -44942,17 +46219,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { + if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; + return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; } } return false; @@ -44984,34 +46261,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 241 /* CatchClause */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 242 /* CatchClause */: return 1 /* Value */; - case 134 /* TypeParameter */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 152 /* TypeLiteral */: + case 135 /* TypeParameter */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 153 /* TypeLiteral */: return 2 /* Type */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 215 /* ModuleDeclaration */: - if (node.name.kind === 8 /* StringLiteral */) { + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -45020,15 +46297,15 @@ var ts; else { return 4 /* Namespace */; } - case 222 /* NamedImports */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 219 /* ImportDeclaration */: - case 224 /* ExportAssignment */: - case 225 /* ExportDeclaration */: + case 223 /* NamedImports */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 220 /* ImportDeclaration */: + case 225 /* ExportAssignment */: + case 226 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 245 /* SourceFile */: + case 246 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -45038,8 +46315,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 /* TypeReference */ || - (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 /* TypeReference */ || + (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -45047,50 +46324,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { + if (root.parent.kind === 164 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || - (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); + return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || + (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132 /* QualifiedName */) { - while (root.parent && root.parent.kind === 132 /* QualifiedName */) { + if (root.parent.kind === 133 /* QualifiedName */) { + while (root.parent && root.parent.kind === 133 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 /* TypeReference */ && !isLastClause; + return root.parent.kind === 149 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132 /* QualifiedName */) { + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 132 /* QualifiedName */ && + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224 /* ExportAssignment */) { + if (node.parent.kind === 225 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -45130,15 +46407,15 @@ var ts; return; } switch (node.kind) { - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 8 /* StringLiteral */: - case 81 /* FalseKeyword */: - case 96 /* TrueKeyword */: - case 90 /* NullKeyword */: - case 92 /* SuperKeyword */: - case 94 /* ThisKeyword */: - case 66 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 9 /* StringLiteral */: + case 82 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 91 /* NullKeyword */: + case 93 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 67 /* Identifier */: break; // Cant create the text span default: @@ -45152,9 +46429,9 @@ var ts; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { // 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 + // 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 === 215 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -45188,17 +46465,17 @@ var ts; // been canceled. That would be an enormous amount of chattyness, along with the all // the overhead of marshalling the data to/from the host. So instead we pick a few // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent + // constructs that we would expect to see commonly, but just at a far less frequent // interval. // // For example, in checker.ts (around 750k) we only have around 600 of these constructs. // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -45252,7 +46529,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 /* ModuleDeclaration */ && + return declaration.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -45262,7 +46539,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -45323,8 +46600,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -45355,13 +46632,13 @@ var ts; // Only bother with the trivia if it at least intersects the span of interest. if (ts.isComment(kind)) { classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner + // Classifying a comment might cause us to reuse the trivia scanner // (because of jsdoc comments). So after we classify the comment make // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { + if (kind === 7 /* ConflictMarkerTrivia */) { var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments @@ -45399,7 +46676,7 @@ var ts; for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { var tag = _a[_i]; // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. + // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } @@ -45407,16 +46684,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -45451,7 +46728,7 @@ var ts; } } function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex + // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. for (var i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { @@ -45487,7 +46764,7 @@ var ts; } } } - // for accurate classification, the actual token should be passed in. however, for + // 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, token) { @@ -45496,7 +46773,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { // 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)) { @@ -45505,30 +46782,30 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54 /* EqualsToken */) { + if (tokenKind === 55 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 208 /* VariableDeclaration */ || - token.parent.kind === 138 /* PropertyDeclaration */ || - token.parent.kind === 135 /* Parameter */) { + if (token.parent.kind === 209 /* VariableDeclaration */ || + token.parent.kind === 139 /* PropertyDeclaration */ || + token.parent.kind === 136 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 178 /* BinaryExpression */ || - token.parent.kind === 176 /* PrefixUnaryExpression */ || - token.parent.kind === 177 /* PostfixUnaryExpression */ || - token.parent.kind === 179 /* ConditionalExpression */) { + if (token.parent.kind === 179 /* BinaryExpression */ || + token.parent.kind === 177 /* PrefixUnaryExpression */ || + token.parent.kind === 178 /* PostfixUnaryExpression */ || + token.parent.kind === 180 /* ConditionalExpression */) { return 5 /* operator */; } } return 10 /* punctuation */; } - else if (tokenKind === 7 /* NumericLiteral */) { + else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 8 /* StringLiteral */) { + else if (tokenKind === 9 /* StringLiteral */) { return 6 /* stringLiteral */; } - else if (tokenKind === 9 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -45536,35 +46813,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 66 /* Identifier */) { + else if (tokenKind === 67 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 135 /* Parameter */: + case 136 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -45630,14 +46907,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; - case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; - case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; - case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; - case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; - case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; + case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; + case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; + case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; + case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; + case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; + case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; + case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; } return undefined; } @@ -45672,12 +46949,73 @@ var ts; } return []; } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a function declaration. + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - methods + // - constructors + // - class decls + var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; + }, ""); + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually + // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call // this on every single file. If we treat this syntactically, then that will cause // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing + // treating this as a semantic operation, we can access any tree without throwing // anything away. synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -45701,7 +47039,7 @@ var ts; // 0) The full match for the entire regexp. // 1) The preamble to the message portion. // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each + // 3...N) The descriptor that was matched - by index. 'undefined' for each // descriptor that didn't match. an actual value if it did match. // // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. @@ -45723,7 +47061,7 @@ var ts; } } ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non + // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; @@ -45768,10 +47106,10 @@ var ts; // (?:(TODO\(jason\))|(HACK)) // // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after + // *are* capture groups. By capturing the inner literals we can determine after // matching which descriptor we are dealing with. var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the + // After matching a descriptor literal, the following regexp matches the rest of the // text up to the end of the line (or */). var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; @@ -45802,7 +47140,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 66 /* Identifier */) { + if (node && node.kind === 67 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -45882,6 +47220,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47241,17 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: nameTable[node.text] = node.text; break; - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: // We want to store any numbers/strings if they were a name that could be // related to a declaration. So, if we have 'import x = require("something")' // 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 === 229 /* ExternalModuleReference */ || + node.parent.kind === 230 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -45925,29 +47264,29 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 /* ElementAccessExpression */ && + node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where - /// we have a series of divide operator. this list allows us to be more accurate by ruling out + /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[66 /* Identifier */] = true; - noRegexTable[8 /* StringLiteral */] = true; - noRegexTable[7 /* NumericLiteral */] = true; - noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[94 /* ThisKeyword */] = true; - noRegexTable[39 /* PlusPlusToken */] = true; - noRegexTable[40 /* MinusMinusToken */] = true; - noRegexTable[17 /* CloseParenToken */] = true; - noRegexTable[19 /* CloseBracketToken */] = true; - noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[96 /* TrueKeyword */] = true; - noRegexTable[81 /* FalseKeyword */] = true; + noRegexTable[67 /* Identifier */] = true; + noRegexTable[9 /* StringLiteral */] = true; + noRegexTable[8 /* NumericLiteral */] = true; + noRegexTable[10 /* RegularExpressionLiteral */] = true; + noRegexTable[95 /* ThisKeyword */] = true; + noRegexTable[40 /* PlusPlusToken */] = true; + noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[18 /* CloseParenToken */] = true; + noRegexTable[20 /* CloseBracketToken */] = true; + noRegexTable[16 /* CloseBraceToken */] = true; + noRegexTable[97 /* TrueKeyword */] = true; + noRegexTable[82 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -45972,11 +47311,11 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 /* GetKeyword */ || - keyword2 === 126 /* SetKeyword */ || - keyword2 === 118 /* ConstructorKeyword */ || - keyword2 === 110 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". + if (keyword2 === 121 /* GetKeyword */ || + keyword2 === 127 /* SetKeyword */ || + keyword2 === 119 /* ConstructorKeyword */ || + keyword2 === 111 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; } @@ -45994,7 +47333,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -46003,8 +47342,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -46074,7 +47413,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47432,83 @@ var ts; // token. So the classification will go back to being an identifier. The moment the user // types again, number will become a keyword, then an identifier, etc. etc. // - // To try to avoid this problem, we avoid classifying contextual keywords as keywords + // To try to avoid this problem, we avoid classifying contextual keywords as keywords // when the user is potentially typing something generic. We just can't do a good enough // job at the lexical level, and so well leave it up to the syntactic classifier to make // the determination. // - // In order to determine if the user is potentially typing something generic, we use a + // In order to determine if the user is potentially typing something generic, we use a // weak heuristic where we track < and > tokens. It's a weak heuristic, but should // work well enough in practice. var angleBracketStack = 0; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { - token = 9 /* RegularExpressionLiteral */; + if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + token = 10 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 66 /* Identifier */; + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 67 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if + // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } - else if (lastNonTriviaToken === 66 /* Identifier */ && - token === 24 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping + else if (lastNonTriviaToken === 67 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 114 /* AnyKeyword */ || - token === 127 /* StringKeyword */ || - token === 125 /* NumberKeyword */ || - token === 117 /* BooleanKeyword */ || - token === 128 /* SymbolKeyword */) { + else if (token === 115 /* AnyKeyword */ || + token === 128 /* StringKeyword */ || + token === 126 /* NumberKeyword */ || + token === 118 /* BooleanKeyword */ || + token === 129 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this + // 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, // causing a noisy experience for the user. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } } - else if (token === 11 /* TemplateHead */) { + else if (token === 12 /* TemplateHead */) { templateStack.push(token); } - else if (token === 14 /* OpenBraceToken */) { + else if (token === 15 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15 /* CloseBraceToken */) { + else if (token === 16 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11 /* TemplateHead */) { + if (lastTemplateStackToken === 12 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 12 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -46184,7 +47523,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -46210,10 +47549,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 10 /* NoSubstitutionTemplateLiteral */) { + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -46221,7 +47560,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -46232,8 +47571,8 @@ var ts; 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 + // 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; } @@ -46251,42 +47590,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: - case 44 /* AmpersandToken */: - case 46 /* CaretToken */: - case 45 /* BarToken */: - case 49 /* AmpersandAmpersandToken */: - case 50 /* BarBarToken */: - case 64 /* BarEqualsToken */: - case 63 /* AmpersandEqualsToken */: - case 65 /* CaretEqualsToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 55 /* PlusEqualsToken */: - case 56 /* MinusEqualsToken */: - case 57 /* AsteriskEqualsToken */: - case 58 /* SlashEqualsToken */: - case 59 /* PercentEqualsToken */: - case 54 /* EqualsToken */: - case 23 /* CommaToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + case 45 /* AmpersandToken */: + case 47 /* CaretToken */: + case 46 /* BarToken */: + case 50 /* AmpersandAmpersandToken */: + case 51 /* BarBarToken */: + case 65 /* BarEqualsToken */: + case 64 /* AmpersandEqualsToken */: + case 66 /* CaretEqualsToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 56 /* PlusEqualsToken */: + case 57 /* MinusEqualsToken */: + case 58 /* AsteriskEqualsToken */: + case 59 /* SlashEqualsToken */: + case 60 /* PercentEqualsToken */: + case 55 /* EqualsToken */: + case 24 /* CommaToken */: return true; default: return false; @@ -46294,19 +47633,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; + return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -46315,24 +47654,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; - case 6 /* ConflictMarkerTrivia */: + case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 66 /* Identifier */: + case 67 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -46364,7 +47703,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -46434,159 +47773,159 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ForStatement */) { + if (node.parent.kind === 197 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 172 /* 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 190 /* VariableStatement */: + case 191 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208 /* VariableDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 209 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return spanInVariableDeclaration(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return spanInParameterDeclaration(node); - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: return spanInBlock(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInBlock(node.block); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 193 /* IfStatement */: + case 194 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInForStatement(node); - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 206 /* TryStatement */: + case 207 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: // span on complete node return textSpan(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23 /* CommaToken */: + case 24 /* CommaToken */: return spanInPreviousNode(node); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 15 /* CloseBraceToken */: + case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return spanInOpenParenToken(node); - case 17 /* CloseParenToken */: + case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 52 /* ColonToken */: + case 53 /* ColonToken */: return spanInColonToken(node); - case 26 /* GreaterThanToken */: - case 24 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return spanInWhileKeyword(node); - case 77 /* ElseKeyword */: - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 78 /* ElseKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -46599,12 +47938,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -46658,7 +47997,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); + (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -46681,18 +48020,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 195 /* WhileStatement */: - case 193 /* IfStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 194 /* IfStatement */: + case 198 /* ForInStatement */: + case 199 /* 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 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -46700,7 +48039,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -46720,13 +48059,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -46734,25 +48073,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 214 /* EnumDeclaration */: - case 211 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -46766,7 +48105,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -46776,17 +48115,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: - case 196 /* ForStatement */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: + case 197 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -46797,19 +48136,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168 /* TypeAssertionExpression */) { + if (node.parent.kind === 169 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -46878,9 +48217,18 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + // if shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -46988,10 +48336,26 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -47098,7 +48462,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -47131,9 +48495,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -47270,7 +48631,10 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; /// COMPLETION LISTS @@ -47318,6 +48682,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { @@ -47401,12 +48769,20 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -47530,4 +48906,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index d5c60023e94..890c77e5ae7 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -23,6 +23,7 @@ declare namespace ts { contains(fileName: string): boolean; remove(fileName: string): void; forEachValue(f: (v: T) => void): void; + clear(): void; } interface TextRange { pos: number; @@ -35,293 +36,294 @@ declare namespace ts { MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, - ConflictMarkerTrivia = 6, - NumericLiteral = 7, - StringLiteral = 8, - RegularExpressionLiteral = 9, - NoSubstitutionTemplateLiteral = 10, - TemplateHead = 11, - TemplateMiddle = 12, - TemplateTail = 13, - OpenBraceToken = 14, - CloseBraceToken = 15, - OpenParenToken = 16, - CloseParenToken = 17, - OpenBracketToken = 18, - CloseBracketToken = 19, - DotToken = 20, - DotDotDotToken = 21, - SemicolonToken = 22, - CommaToken = 23, - LessThanToken = 24, - LessThanSlashToken = 25, - GreaterThanToken = 26, - LessThanEqualsToken = 27, - GreaterThanEqualsToken = 28, - EqualsEqualsToken = 29, - ExclamationEqualsToken = 30, - EqualsEqualsEqualsToken = 31, - ExclamationEqualsEqualsToken = 32, - EqualsGreaterThanToken = 33, - PlusToken = 34, - MinusToken = 35, - AsteriskToken = 36, - SlashToken = 37, - PercentToken = 38, - PlusPlusToken = 39, - MinusMinusToken = 40, - LessThanLessThanToken = 41, - GreaterThanGreaterThanToken = 42, - GreaterThanGreaterThanGreaterThanToken = 43, - AmpersandToken = 44, - BarToken = 45, - CaretToken = 46, - ExclamationToken = 47, - TildeToken = 48, - AmpersandAmpersandToken = 49, - BarBarToken = 50, - QuestionToken = 51, - ColonToken = 52, - AtToken = 53, - EqualsToken = 54, - PlusEqualsToken = 55, - MinusEqualsToken = 56, - AsteriskEqualsToken = 57, - SlashEqualsToken = 58, - PercentEqualsToken = 59, - LessThanLessThanEqualsToken = 60, - GreaterThanGreaterThanEqualsToken = 61, - GreaterThanGreaterThanGreaterThanEqualsToken = 62, - AmpersandEqualsToken = 63, - BarEqualsToken = 64, - CaretEqualsToken = 65, - Identifier = 66, - BreakKeyword = 67, - CaseKeyword = 68, - CatchKeyword = 69, - ClassKeyword = 70, - ConstKeyword = 71, - ContinueKeyword = 72, - DebuggerKeyword = 73, - DefaultKeyword = 74, - DeleteKeyword = 75, - DoKeyword = 76, - ElseKeyword = 77, - EnumKeyword = 78, - ExportKeyword = 79, - ExtendsKeyword = 80, - FalseKeyword = 81, - FinallyKeyword = 82, - ForKeyword = 83, - FunctionKeyword = 84, - IfKeyword = 85, - ImportKeyword = 86, - InKeyword = 87, - InstanceOfKeyword = 88, - NewKeyword = 89, - NullKeyword = 90, - ReturnKeyword = 91, - SuperKeyword = 92, - SwitchKeyword = 93, - ThisKeyword = 94, - ThrowKeyword = 95, - TrueKeyword = 96, - TryKeyword = 97, - TypeOfKeyword = 98, - VarKeyword = 99, - VoidKeyword = 100, - WhileKeyword = 101, - WithKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AbstractKeyword = 112, - AsKeyword = 113, - AnyKeyword = 114, - AsyncKeyword = 115, - AwaitKeyword = 116, - BooleanKeyword = 117, - ConstructorKeyword = 118, - DeclareKeyword = 119, - GetKeyword = 120, - IsKeyword = 121, - ModuleKeyword = 122, - NamespaceKeyword = 123, - RequireKeyword = 124, - NumberKeyword = 125, - SetKeyword = 126, - StringKeyword = 127, - SymbolKeyword = 128, - TypeKeyword = 129, - FromKeyword = 130, - OfKeyword = 131, - QualifiedName = 132, - ComputedPropertyName = 133, - TypeParameter = 134, - Parameter = 135, - Decorator = 136, - PropertySignature = 137, - PropertyDeclaration = 138, - MethodSignature = 139, - MethodDeclaration = 140, - Constructor = 141, - GetAccessor = 142, - SetAccessor = 143, - CallSignature = 144, - ConstructSignature = 145, - IndexSignature = 146, - TypePredicate = 147, - TypeReference = 148, - FunctionType = 149, - ConstructorType = 150, - TypeQuery = 151, - TypeLiteral = 152, - ArrayType = 153, - TupleType = 154, - UnionType = 155, - IntersectionType = 156, - ParenthesizedType = 157, - ObjectBindingPattern = 158, - ArrayBindingPattern = 159, - BindingElement = 160, - ArrayLiteralExpression = 161, - ObjectLiteralExpression = 162, - PropertyAccessExpression = 163, - ElementAccessExpression = 164, - CallExpression = 165, - NewExpression = 166, - TaggedTemplateExpression = 167, - TypeAssertionExpression = 168, - ParenthesizedExpression = 169, - FunctionExpression = 170, - ArrowFunction = 171, - DeleteExpression = 172, - TypeOfExpression = 173, - VoidExpression = 174, - AwaitExpression = 175, - PrefixUnaryExpression = 176, - PostfixUnaryExpression = 177, - BinaryExpression = 178, - ConditionalExpression = 179, - TemplateExpression = 180, - YieldExpression = 181, - SpreadElementExpression = 182, - ClassExpression = 183, - OmittedExpression = 184, - ExpressionWithTypeArguments = 185, - AsExpression = 186, - TemplateSpan = 187, - SemicolonClassElement = 188, - Block = 189, - VariableStatement = 190, - EmptyStatement = 191, - ExpressionStatement = 192, - IfStatement = 193, - DoStatement = 194, - WhileStatement = 195, - ForStatement = 196, - ForInStatement = 197, - ForOfStatement = 198, - ContinueStatement = 199, - BreakStatement = 200, - ReturnStatement = 201, - WithStatement = 202, - SwitchStatement = 203, - LabeledStatement = 204, - ThrowStatement = 205, - TryStatement = 206, - DebuggerStatement = 207, - VariableDeclaration = 208, - VariableDeclarationList = 209, - FunctionDeclaration = 210, - ClassDeclaration = 211, - InterfaceDeclaration = 212, - TypeAliasDeclaration = 213, - EnumDeclaration = 214, - ModuleDeclaration = 215, - ModuleBlock = 216, - CaseBlock = 217, - ImportEqualsDeclaration = 218, - ImportDeclaration = 219, - ImportClause = 220, - NamespaceImport = 221, - NamedImports = 222, - ImportSpecifier = 223, - ExportAssignment = 224, - ExportDeclaration = 225, - NamedExports = 226, - ExportSpecifier = 227, - MissingDeclaration = 228, - ExternalModuleReference = 229, - JsxElement = 230, - JsxSelfClosingElement = 231, - JsxOpeningElement = 232, - JsxText = 233, - JsxClosingElement = 234, - JsxAttribute = 235, - JsxSpreadAttribute = 236, - JsxExpression = 237, - CaseClause = 238, - DefaultClause = 239, - HeritageClause = 240, - CatchClause = 241, - PropertyAssignment = 242, - ShorthandPropertyAssignment = 243, - EnumMember = 244, - SourceFile = 245, - JSDocTypeExpression = 246, - JSDocAllType = 247, - JSDocUnknownType = 248, - JSDocArrayType = 249, - JSDocUnionType = 250, - JSDocTupleType = 251, - JSDocNullableType = 252, - JSDocNonNullableType = 253, - JSDocRecordType = 254, - JSDocRecordMember = 255, - JSDocTypeReference = 256, - JSDocOptionalType = 257, - JSDocFunctionType = 258, - JSDocVariadicType = 259, - JSDocConstructorType = 260, - JSDocThisType = 261, - JSDocComment = 262, - JSDocTag = 263, - JSDocParameterTag = 264, - JSDocReturnTag = 265, - JSDocTypeTag = 266, - JSDocTemplateTag = 267, - SyntaxList = 268, - Count = 269, - FirstAssignment = 54, - LastAssignment = 65, - FirstReservedWord = 67, - LastReservedWord = 102, - FirstKeyword = 67, - LastKeyword = 131, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, - FirstTypeNode = 148, - LastTypeNode = 157, - FirstPunctuation = 14, - LastPunctuation = 65, + ShebangTrivia = 6, + ConflictMarkerTrivia = 7, + NumericLiteral = 8, + StringLiteral = 9, + RegularExpressionLiteral = 10, + NoSubstitutionTemplateLiteral = 11, + TemplateHead = 12, + TemplateMiddle = 13, + TemplateTail = 14, + OpenBraceToken = 15, + CloseBraceToken = 16, + OpenParenToken = 17, + CloseParenToken = 18, + OpenBracketToken = 19, + CloseBracketToken = 20, + DotToken = 21, + DotDotDotToken = 22, + SemicolonToken = 23, + CommaToken = 24, + LessThanToken = 25, + LessThanSlashToken = 26, + GreaterThanToken = 27, + LessThanEqualsToken = 28, + GreaterThanEqualsToken = 29, + EqualsEqualsToken = 30, + ExclamationEqualsToken = 31, + EqualsEqualsEqualsToken = 32, + ExclamationEqualsEqualsToken = 33, + EqualsGreaterThanToken = 34, + PlusToken = 35, + MinusToken = 36, + AsteriskToken = 37, + SlashToken = 38, + PercentToken = 39, + PlusPlusToken = 40, + MinusMinusToken = 41, + LessThanLessThanToken = 42, + GreaterThanGreaterThanToken = 43, + GreaterThanGreaterThanGreaterThanToken = 44, + AmpersandToken = 45, + BarToken = 46, + CaretToken = 47, + ExclamationToken = 48, + TildeToken = 49, + AmpersandAmpersandToken = 50, + BarBarToken = 51, + QuestionToken = 52, + ColonToken = 53, + AtToken = 54, + EqualsToken = 55, + PlusEqualsToken = 56, + MinusEqualsToken = 57, + AsteriskEqualsToken = 58, + SlashEqualsToken = 59, + PercentEqualsToken = 60, + LessThanLessThanEqualsToken = 61, + GreaterThanGreaterThanEqualsToken = 62, + GreaterThanGreaterThanGreaterThanEqualsToken = 63, + AmpersandEqualsToken = 64, + BarEqualsToken = 65, + CaretEqualsToken = 66, + Identifier = 67, + BreakKeyword = 68, + CaseKeyword = 69, + CatchKeyword = 70, + ClassKeyword = 71, + ConstKeyword = 72, + ContinueKeyword = 73, + DebuggerKeyword = 74, + DefaultKeyword = 75, + DeleteKeyword = 76, + DoKeyword = 77, + ElseKeyword = 78, + EnumKeyword = 79, + ExportKeyword = 80, + ExtendsKeyword = 81, + FalseKeyword = 82, + FinallyKeyword = 83, + ForKeyword = 84, + FunctionKeyword = 85, + IfKeyword = 86, + ImportKeyword = 87, + InKeyword = 88, + InstanceOfKeyword = 89, + NewKeyword = 90, + NullKeyword = 91, + ReturnKeyword = 92, + SuperKeyword = 93, + SwitchKeyword = 94, + ThisKeyword = 95, + ThrowKeyword = 96, + TrueKeyword = 97, + TryKeyword = 98, + TypeOfKeyword = 99, + VarKeyword = 100, + VoidKeyword = 101, + WhileKeyword = 102, + WithKeyword = 103, + ImplementsKeyword = 104, + InterfaceKeyword = 105, + LetKeyword = 106, + PackageKeyword = 107, + PrivateKeyword = 108, + ProtectedKeyword = 109, + PublicKeyword = 110, + StaticKeyword = 111, + YieldKeyword = 112, + AbstractKeyword = 113, + AsKeyword = 114, + AnyKeyword = 115, + AsyncKeyword = 116, + AwaitKeyword = 117, + BooleanKeyword = 118, + ConstructorKeyword = 119, + DeclareKeyword = 120, + GetKeyword = 121, + IsKeyword = 122, + ModuleKeyword = 123, + NamespaceKeyword = 124, + RequireKeyword = 125, + NumberKeyword = 126, + SetKeyword = 127, + StringKeyword = 128, + SymbolKeyword = 129, + TypeKeyword = 130, + FromKeyword = 131, + OfKeyword = 132, + QualifiedName = 133, + ComputedPropertyName = 134, + TypeParameter = 135, + Parameter = 136, + Decorator = 137, + PropertySignature = 138, + PropertyDeclaration = 139, + MethodSignature = 140, + MethodDeclaration = 141, + Constructor = 142, + GetAccessor = 143, + SetAccessor = 144, + CallSignature = 145, + ConstructSignature = 146, + IndexSignature = 147, + TypePredicate = 148, + TypeReference = 149, + FunctionType = 150, + ConstructorType = 151, + TypeQuery = 152, + TypeLiteral = 153, + ArrayType = 154, + TupleType = 155, + UnionType = 156, + IntersectionType = 157, + ParenthesizedType = 158, + ObjectBindingPattern = 159, + ArrayBindingPattern = 160, + BindingElement = 161, + ArrayLiteralExpression = 162, + ObjectLiteralExpression = 163, + PropertyAccessExpression = 164, + ElementAccessExpression = 165, + CallExpression = 166, + NewExpression = 167, + TaggedTemplateExpression = 168, + TypeAssertionExpression = 169, + ParenthesizedExpression = 170, + FunctionExpression = 171, + ArrowFunction = 172, + DeleteExpression = 173, + TypeOfExpression = 174, + VoidExpression = 175, + AwaitExpression = 176, + PrefixUnaryExpression = 177, + PostfixUnaryExpression = 178, + BinaryExpression = 179, + ConditionalExpression = 180, + TemplateExpression = 181, + YieldExpression = 182, + SpreadElementExpression = 183, + ClassExpression = 184, + OmittedExpression = 185, + ExpressionWithTypeArguments = 186, + AsExpression = 187, + TemplateSpan = 188, + SemicolonClassElement = 189, + Block = 190, + VariableStatement = 191, + EmptyStatement = 192, + ExpressionStatement = 193, + IfStatement = 194, + DoStatement = 195, + WhileStatement = 196, + ForStatement = 197, + ForInStatement = 198, + ForOfStatement = 199, + ContinueStatement = 200, + BreakStatement = 201, + ReturnStatement = 202, + WithStatement = 203, + SwitchStatement = 204, + LabeledStatement = 205, + ThrowStatement = 206, + TryStatement = 207, + DebuggerStatement = 208, + VariableDeclaration = 209, + VariableDeclarationList = 210, + FunctionDeclaration = 211, + ClassDeclaration = 212, + InterfaceDeclaration = 213, + TypeAliasDeclaration = 214, + EnumDeclaration = 215, + ModuleDeclaration = 216, + ModuleBlock = 217, + CaseBlock = 218, + ImportEqualsDeclaration = 219, + ImportDeclaration = 220, + ImportClause = 221, + NamespaceImport = 222, + NamedImports = 223, + ImportSpecifier = 224, + ExportAssignment = 225, + ExportDeclaration = 226, + NamedExports = 227, + ExportSpecifier = 228, + MissingDeclaration = 229, + ExternalModuleReference = 230, + JsxElement = 231, + JsxSelfClosingElement = 232, + JsxOpeningElement = 233, + JsxText = 234, + JsxClosingElement = 235, + JsxAttribute = 236, + JsxSpreadAttribute = 237, + JsxExpression = 238, + CaseClause = 239, + DefaultClause = 240, + HeritageClause = 241, + CatchClause = 242, + PropertyAssignment = 243, + ShorthandPropertyAssignment = 244, + EnumMember = 245, + SourceFile = 246, + JSDocTypeExpression = 247, + JSDocAllType = 248, + JSDocUnknownType = 249, + JSDocArrayType = 250, + JSDocUnionType = 251, + JSDocTupleType = 252, + JSDocNullableType = 253, + JSDocNonNullableType = 254, + JSDocRecordType = 255, + JSDocRecordMember = 256, + JSDocTypeReference = 257, + JSDocOptionalType = 258, + JSDocFunctionType = 259, + JSDocVariadicType = 260, + JSDocConstructorType = 261, + JSDocThisType = 262, + JSDocComment = 263, + JSDocTag = 264, + JSDocParameterTag = 265, + JSDocReturnTag = 266, + JSDocTypeTag = 267, + JSDocTemplateTag = 268, + SyntaxList = 269, + Count = 270, + FirstAssignment = 55, + LastAssignment = 66, + FirstReservedWord = 68, + LastReservedWord = 103, + FirstKeyword = 68, + LastKeyword = 132, + FirstFutureReservedWord = 104, + LastFutureReservedWord = 112, + FirstTypeNode = 149, + LastTypeNode = 158, + FirstPunctuation = 15, + LastPunctuation = 66, FirstToken = 0, - LastToken = 131, + LastToken = 132, FirstTriviaToken = 2, - LastTriviaToken = 6, - FirstLiteralToken = 7, - LastLiteralToken = 10, - FirstTemplateToken = 10, - LastTemplateToken = 13, - FirstBinaryOperator = 24, - LastBinaryOperator = 65, - FirstNode = 132, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 66, + FirstNode = 133, } const enum NodeFlags { Export = 1, @@ -452,9 +454,9 @@ declare namespace ts { * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclaration. * Examples: - * FunctionDeclaration - * MethodDeclaration - * AccessorDeclaration + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; @@ -944,7 +946,7 @@ declare namespace ts { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } - interface ParseConfigHost { + interface ParseConfigHost extends ModuleResolutionHost { readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; } interface WriteFileCallback { @@ -958,6 +960,10 @@ declare namespace ts { throwIfCancellationRequested(): void; } interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; /** * Get a list of files in the program */ @@ -1026,6 +1032,7 @@ declare namespace ts { getPropertyOfType(type: Type, propertyName: string): Symbol; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -1049,6 +1056,7 @@ declare namespace ts { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1193,7 +1201,7 @@ declare namespace ts { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1213,8 +1221,6 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1310,6 +1316,7 @@ declare namespace ts { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1362,14 +1369,25 @@ declare namespace ts { fileNames: string[]; errors: Diagnostic[]; } - interface CompilerHost { + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + failedLookupLocations: string[]; + } + type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule; + interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface TextSpan { start: number; @@ -1443,9 +1461,11 @@ declare namespace ts { function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant: ts.LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -1485,13 +1505,14 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { - /** The version of the TypeScript compiler release */ const version: string; function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { function parseCommandLine(commandLine: string[]): ParsedCommandLine; @@ -1555,6 +1576,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1596,6 +1618,7 @@ declare namespace ts { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1616,6 +1639,7 @@ declare namespace ts { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1656,6 +1680,7 @@ declare namespace ts { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; getSourceFile(fileName: string): SourceFile; @@ -1692,6 +1717,11 @@ declare namespace ts { span: TextSpan; newText: string; } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } interface RenameLocation { textSpan: TextSpan; fileName: string; @@ -1712,6 +1742,7 @@ declare namespace ts { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1739,6 +1770,7 @@ declare namespace ts { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1981,6 +2013,7 @@ declare namespace ts { * @param compilationSettings The compilation settings used to acquire the file */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; } module ScriptElementKind { const unknown: string; @@ -2067,10 +2100,24 @@ declare namespace ts { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 6035d71fa2b..9507f25db63 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -16,6 +16,7 @@ and limitations under the License. var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -23,324 +24,326 @@ var ts; SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 6] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 7] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 8] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 9] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 10] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 11] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 12] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 13] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 14] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 15] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 16] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 17] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 18] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 19] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 20] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 21] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 10] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -602,21 +605,27 @@ var ts; TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -822,6 +831,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +853,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1003,13 @@ var ts; return array[array.length - 1]; } ts.lastOrUndefined = lastOrUndefined; + /** + * Performs a binary search, finding the index at which 'value' occurs in 'array'. + * If no such index is found, returns the 2's-complement of first index at which + * number[index] exceeds number. + * @param array A sorted array whose first element must be no larger than number + * @param number The value to be searched for in the array. + */ function binarySearch(array, value) { var low = 0; var high = array.length - 1; @@ -1293,7 +1313,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -1470,7 +1490,7 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1699,7 +1719,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1734,7 +1754,7 @@ var ts; function writeFile(fileName, data, writeByteOrderMark) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -1775,7 +1795,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -1799,7 +1819,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1855,9 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + // process and process.nextTick checks if current environment is node-like + // process.browser check excludes webpack and browserify return getNodeSystem(); } else { @@ -2101,6 +2122,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -2140,7 +2162,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -2271,6 +2293,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, 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}'." }, @@ -2350,20 +2374,11 @@ var ts; 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}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.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: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_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 'isolatedModules' 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." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, 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." }, @@ -2414,7 +2429,6 @@ var ts; 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'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, @@ -2459,7 +2473,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -2467,123 +2482,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112 /* AbstractKeyword */, - "any": 114 /* AnyKeyword */, - "as": 113 /* AsKeyword */, - "boolean": 117 /* BooleanKeyword */, - "break": 67 /* BreakKeyword */, - "case": 68 /* CaseKeyword */, - "catch": 69 /* CatchKeyword */, - "class": 70 /* ClassKeyword */, - "continue": 72 /* ContinueKeyword */, - "const": 71 /* ConstKeyword */, - "constructor": 118 /* ConstructorKeyword */, - "debugger": 73 /* DebuggerKeyword */, - "declare": 119 /* DeclareKeyword */, - "default": 74 /* DefaultKeyword */, - "delete": 75 /* DeleteKeyword */, - "do": 76 /* DoKeyword */, - "else": 77 /* ElseKeyword */, - "enum": 78 /* EnumKeyword */, - "export": 79 /* ExportKeyword */, - "extends": 80 /* ExtendsKeyword */, - "false": 81 /* FalseKeyword */, - "finally": 82 /* FinallyKeyword */, - "for": 83 /* ForKeyword */, - "from": 130 /* FromKeyword */, - "function": 84 /* FunctionKeyword */, - "get": 120 /* GetKeyword */, - "if": 85 /* IfKeyword */, - "implements": 103 /* ImplementsKeyword */, - "import": 86 /* ImportKeyword */, - "in": 87 /* InKeyword */, - "instanceof": 88 /* InstanceOfKeyword */, - "interface": 104 /* InterfaceKeyword */, - "is": 121 /* IsKeyword */, - "let": 105 /* LetKeyword */, - "module": 122 /* ModuleKeyword */, - "namespace": 123 /* NamespaceKeyword */, - "new": 89 /* NewKeyword */, - "null": 90 /* NullKeyword */, - "number": 125 /* NumberKeyword */, - "package": 106 /* PackageKeyword */, - "private": 107 /* PrivateKeyword */, - "protected": 108 /* ProtectedKeyword */, - "public": 109 /* PublicKeyword */, - "require": 124 /* RequireKeyword */, - "return": 91 /* ReturnKeyword */, - "set": 126 /* SetKeyword */, - "static": 110 /* StaticKeyword */, - "string": 127 /* StringKeyword */, - "super": 92 /* SuperKeyword */, - "switch": 93 /* SwitchKeyword */, - "symbol": 128 /* SymbolKeyword */, - "this": 94 /* ThisKeyword */, - "throw": 95 /* ThrowKeyword */, - "true": 96 /* TrueKeyword */, - "try": 97 /* TryKeyword */, - "type": 129 /* TypeKeyword */, - "typeof": 98 /* TypeOfKeyword */, - "var": 99 /* VarKeyword */, - "void": 100 /* VoidKeyword */, - "while": 101 /* WhileKeyword */, - "with": 102 /* WithKeyword */, - "yield": 111 /* YieldKeyword */, - "async": 115 /* AsyncKeyword */, - "await": 116 /* AwaitKeyword */, - "of": 131 /* OfKeyword */, - "{": 14 /* OpenBraceToken */, - "}": 15 /* CloseBraceToken */, - "(": 16 /* OpenParenToken */, - ")": 17 /* CloseParenToken */, - "[": 18 /* OpenBracketToken */, - "]": 19 /* CloseBracketToken */, - ".": 20 /* DotToken */, - "...": 21 /* DotDotDotToken */, - ";": 22 /* SemicolonToken */, - ",": 23 /* CommaToken */, - "<": 24 /* LessThanToken */, - ">": 26 /* GreaterThanToken */, - "<=": 27 /* LessThanEqualsToken */, - ">=": 28 /* GreaterThanEqualsToken */, - "==": 29 /* EqualsEqualsToken */, - "!=": 30 /* ExclamationEqualsToken */, - "===": 31 /* EqualsEqualsEqualsToken */, - "!==": 32 /* ExclamationEqualsEqualsToken */, - "=>": 33 /* EqualsGreaterThanToken */, - "+": 34 /* PlusToken */, - "-": 35 /* MinusToken */, - "*": 36 /* AsteriskToken */, - "/": 37 /* SlashToken */, - "%": 38 /* PercentToken */, - "++": 39 /* PlusPlusToken */, - "--": 40 /* MinusMinusToken */, - "<<": 41 /* LessThanLessThanToken */, - ">": 42 /* GreaterThanGreaterThanToken */, - ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 44 /* AmpersandToken */, - "|": 45 /* BarToken */, - "^": 46 /* CaretToken */, - "!": 47 /* ExclamationToken */, - "~": 48 /* TildeToken */, - "&&": 49 /* AmpersandAmpersandToken */, - "||": 50 /* BarBarToken */, - "?": 51 /* QuestionToken */, - ":": 52 /* ColonToken */, - "=": 54 /* EqualsToken */, - "+=": 55 /* PlusEqualsToken */, - "-=": 56 /* MinusEqualsToken */, - "*=": 57 /* AsteriskEqualsToken */, - "/=": 58 /* SlashEqualsToken */, - "%=": 59 /* PercentEqualsToken */, - "<<=": 60 /* LessThanLessThanEqualsToken */, - ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 63 /* AmpersandEqualsToken */, - "|=": 64 /* BarEqualsToken */, - "^=": 65 /* CaretEqualsToken */, - "@": 53 /* AtToken */ + "abstract": 113 /* AbstractKeyword */, + "any": 115 /* AnyKeyword */, + "as": 114 /* AsKeyword */, + "boolean": 118 /* BooleanKeyword */, + "break": 68 /* BreakKeyword */, + "case": 69 /* CaseKeyword */, + "catch": 70 /* CatchKeyword */, + "class": 71 /* ClassKeyword */, + "continue": 73 /* ContinueKeyword */, + "const": 72 /* ConstKeyword */, + "constructor": 119 /* ConstructorKeyword */, + "debugger": 74 /* DebuggerKeyword */, + "declare": 120 /* DeclareKeyword */, + "default": 75 /* DefaultKeyword */, + "delete": 76 /* DeleteKeyword */, + "do": 77 /* DoKeyword */, + "else": 78 /* ElseKeyword */, + "enum": 79 /* EnumKeyword */, + "export": 80 /* ExportKeyword */, + "extends": 81 /* ExtendsKeyword */, + "false": 82 /* FalseKeyword */, + "finally": 83 /* FinallyKeyword */, + "for": 84 /* ForKeyword */, + "from": 131 /* FromKeyword */, + "function": 85 /* FunctionKeyword */, + "get": 121 /* GetKeyword */, + "if": 86 /* IfKeyword */, + "implements": 104 /* ImplementsKeyword */, + "import": 87 /* ImportKeyword */, + "in": 88 /* InKeyword */, + "instanceof": 89 /* InstanceOfKeyword */, + "interface": 105 /* InterfaceKeyword */, + "is": 122 /* IsKeyword */, + "let": 106 /* LetKeyword */, + "module": 123 /* ModuleKeyword */, + "namespace": 124 /* NamespaceKeyword */, + "new": 90 /* NewKeyword */, + "null": 91 /* NullKeyword */, + "number": 126 /* NumberKeyword */, + "package": 107 /* PackageKeyword */, + "private": 108 /* PrivateKeyword */, + "protected": 109 /* ProtectedKeyword */, + "public": 110 /* PublicKeyword */, + "require": 125 /* RequireKeyword */, + "return": 92 /* ReturnKeyword */, + "set": 127 /* SetKeyword */, + "static": 111 /* StaticKeyword */, + "string": 128 /* StringKeyword */, + "super": 93 /* SuperKeyword */, + "switch": 94 /* SwitchKeyword */, + "symbol": 129 /* SymbolKeyword */, + "this": 95 /* ThisKeyword */, + "throw": 96 /* ThrowKeyword */, + "true": 97 /* TrueKeyword */, + "try": 98 /* TryKeyword */, + "type": 130 /* TypeKeyword */, + "typeof": 99 /* TypeOfKeyword */, + "var": 100 /* VarKeyword */, + "void": 101 /* VoidKeyword */, + "while": 102 /* WhileKeyword */, + "with": 103 /* WithKeyword */, + "yield": 112 /* YieldKeyword */, + "async": 116 /* AsyncKeyword */, + "await": 117 /* AwaitKeyword */, + "of": 132 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 18 /* CloseParenToken */, + "[": 19 /* OpenBracketToken */, + "]": 20 /* CloseBracketToken */, + ".": 21 /* DotToken */, + "...": 22 /* DotDotDotToken */, + ";": 23 /* SemicolonToken */, + ",": 24 /* CommaToken */, + "<": 25 /* LessThanToken */, + ">": 27 /* GreaterThanToken */, + "<=": 28 /* LessThanEqualsToken */, + ">=": 29 /* GreaterThanEqualsToken */, + "==": 30 /* EqualsEqualsToken */, + "!=": 31 /* ExclamationEqualsToken */, + "===": 32 /* EqualsEqualsEqualsToken */, + "!==": 33 /* ExclamationEqualsEqualsToken */, + "=>": 34 /* EqualsGreaterThanToken */, + "+": 35 /* PlusToken */, + "-": 36 /* MinusToken */, + "*": 37 /* AsteriskToken */, + "/": 38 /* SlashToken */, + "%": 39 /* PercentToken */, + "++": 40 /* PlusPlusToken */, + "--": 41 /* MinusMinusToken */, + "<<": 42 /* LessThanLessThanToken */, + ">": 43 /* GreaterThanGreaterThanToken */, + ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 45 /* AmpersandToken */, + "|": 46 /* BarToken */, + "^": 47 /* CaretToken */, + "!": 48 /* ExclamationToken */, + "~": 49 /* TildeToken */, + "&&": 50 /* AmpersandAmpersandToken */, + "||": 51 /* BarBarToken */, + "?": 52 /* QuestionToken */, + ":": 53 /* ColonToken */, + "=": 55 /* EqualsToken */, + "+=": 56 /* PlusEqualsToken */, + "-=": 57 /* MinusEqualsToken */, + "*=": 58 /* AsteriskEqualsToken */, + "/=": 59 /* SlashEqualsToken */, + "%=": 60 /* PercentEqualsToken */, + "<<=": 61 /* LessThanLessThanEqualsToken */, + ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 64 /* AmpersandEqualsToken */, + "|=": 65 /* BarEqualsToken */, + "^=": 66 /* CaretEqualsToken */, + "@": 54 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2730,14 +2745,21 @@ var ts; } ts.getLineStarts = getLineStarts; /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { // If the actual position was not found, - // the binary search returns the negative value of the next line start + // the binary search returns the 2's-complement of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -2809,6 +2831,9 @@ var ts; case 62 /* greaterThan */: // Starts of conflict marker trivia return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; default: return ch > 127 /* maxAsciiCharacter */; } @@ -2867,6 +2892,12 @@ var ts; continue; } break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2923,13 +2954,28 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -3004,13 +3050,20 @@ var ts; } } function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); + return getCommentRanges(text, pos, /*trailing*/ false); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); + return getCommentRanges(text, pos, /*trailing*/ true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || @@ -3023,7 +3076,6 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } @@ -3050,8 +3102,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, + isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3121,14 +3173,14 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); } /** * Scans as many hexadecimal digits as are available in the text, * returning -1 if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); } function scanHexDigits(minCount, scanAsManyAsPossible) { var digits = 0; @@ -3203,7 +3255,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -3211,14 +3263,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; break; } // Escape character @@ -3280,10 +3332,10 @@ var ts; return scanExtendedUnicodeEscape(); } // '\uDDDD' - return scanHexadecimalEscape(4); + return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: // '\xDD' - return scanHexadecimalEscape(2); + return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". case 13 /* carriageReturn */: @@ -3395,7 +3447,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66 /* Identifier */; + return token = 67 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3430,6 +3482,16 @@ var ts; return token = 1 /* EndOfFileToken */; } var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } switch (ch) { case 10 /* lineFeed */: case 13 /* carriageReturn */: @@ -3465,66 +3527,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 30 /* ExclamationEqualsToken */; + return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 47 /* ExclamationToken */; + return pos++, token = 48 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 8 /* StringLiteral */; + return token = 9 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PercentEqualsToken */; + return pos += 2, token = 60 /* PercentEqualsToken */; } - return pos++, token = 38 /* PercentToken */; + return pos++, token = 39 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 49 /* AmpersandAmpersandToken */; + return pos += 2, token = 50 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AmpersandEqualsToken */; + return pos += 2, token = 64 /* AmpersandEqualsToken */; } - return pos++, token = 44 /* AmpersandToken */; + return pos++, token = 45 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 16 /* OpenParenToken */; + return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 17 /* CloseParenToken */; + return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* AsteriskEqualsToken */; + return pos += 2, token = 58 /* AsteriskEqualsToken */; } - return pos++, token = 36 /* AsteriskToken */; + return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 39 /* PlusPlusToken */; + return pos += 2, token = 40 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* PlusEqualsToken */; + return pos += 2, token = 56 /* PlusEqualsToken */; } - return pos++, token = 34 /* PlusToken */; + return pos++, token = 35 /* PlusToken */; case 44 /* comma */: - return pos++, token = 23 /* CommaToken */; + return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 40 /* MinusMinusToken */; + return pos += 2, token = 41 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* MinusEqualsToken */; + return pos += 2, token = 57 /* MinusEqualsToken */; } - return pos++, token = 35 /* MinusToken */; + return pos++, token = 36 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 21 /* DotDotDotToken */; + return pos += 3, token = 22 /* DotDotDotToken */; } - return pos++, token = 20 /* DotToken */; + return pos++, token = 21 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -3570,9 +3632,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* SlashEqualsToken */; + return pos += 2, token = 59 /* SlashEqualsToken */; } - return pos++, token = 37 /* SlashToken */; + return pos++, token = 38 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3582,32 +3644,32 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(2); + var value = scanBinaryOrOctalDigits(/* base */ 2); if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(8); + var value = scanBinaryOrOctalDigits(/* base */ 8); if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being @@ -3622,11 +3684,11 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 52 /* ColonToken */; + return pos++, token = 53 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 22 /* SemicolonToken */; + return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3634,22 +3696,22 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 41 /* LessThanLessThanToken */; + return pos += 2, token = 42 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 27 /* LessThanEqualsToken */; + return pos += 2, token = 28 /* LessThanEqualsToken */; } if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { - return pos += 2, token = 25 /* LessThanSlashToken */; + return pos += 2, token = 26 /* LessThanSlashToken */; } - return pos++, token = 24 /* LessThanToken */; + return pos++, token = 25 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3657,19 +3719,19 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 29 /* EqualsEqualsToken */; + return pos += 2, token = 30 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 33 /* EqualsGreaterThanToken */; + return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 54 /* EqualsToken */; + return pos++, token = 55 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3677,37 +3739,37 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } - return pos++, token = 26 /* GreaterThanToken */; + return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 51 /* QuestionToken */; + return pos++, token = 52 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 18 /* OpenBracketToken */; + return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 19 /* CloseBracketToken */; + return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* CaretEqualsToken */; + return pos += 2, token = 66 /* CaretEqualsToken */; } - return pos++, token = 46 /* CaretToken */; + return pos++, token = 47 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 14 /* OpenBraceToken */; + return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 50 /* BarBarToken */; + return pos += 2, token = 51 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* BarEqualsToken */; + return pos += 2, token = 65 /* BarEqualsToken */; } - return pos++, token = 45 /* BarToken */; + return pos++, token = 46 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 15 /* CloseBraceToken */; + return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 48 /* TildeToken */; + return pos++, token = 49 /* TildeToken */; case 64 /* at */: - return pos++, token = 53 /* AtToken */; + return pos++, token = 54 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3743,27 +3805,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26 /* GreaterThanToken */) { + if (token === 27 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 42 /* GreaterThanGreaterThanToken */; + return pos++, token = 43 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 28 /* GreaterThanEqualsToken */; + return pos++, token = 29 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { + if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3808,7 +3870,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3878,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -3833,14 +3895,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 25 /* LessThanSlashToken */; + return token = 26 /* LessThanSlashToken */; } pos++; - return token = 24 /* LessThanToken */; + return token = 25 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 14 /* OpenBraceToken */; + return token = 15 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -3849,12 +3911,12 @@ var ts; break; } } - return token = 233 /* JsxText */; + return token = 234 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -3890,10 +3952,10 @@ var ts; return result; } function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookahead:*/ true); } function tryScan(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookahead:*/ false); } function setText(newText, start, length) { text = newText || ""; @@ -3937,16 +3999,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 216 /* ModuleBlock */) { + else if (node.kind === 217 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3965,7 +4027,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4105,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { - return '"' + node.name.text + '"'; + if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4054,22 +4116,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return "__constructor"; - case 149 /* FunctionType */: - case 144 /* CallSignature */: + case 150 /* FunctionType */: + case 145 /* CallSignature */: return "__call"; - case 150 /* ConstructorType */: - case 145 /* ConstructSignature */: + case 151 /* ConstructorType */: + case 146 /* ConstructSignature */: return "__new"; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return "__index"; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return "__export"; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4140,7 +4202,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4221,37 +4283,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 215 /* ModuleDeclaration */: - case 245 /* SourceFile */: - case 213 /* TypeAliasDeclaration */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 216 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 214 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 241 /* CatchClause */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 217 /* CaseBlock */: + case 242 /* CatchClause */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 218 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 189 /* Block */: + case 190 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4288,38 +4350,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: - case 212 /* InterfaceDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: + case 213 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 213 /* TypeAliasDeclaration */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 214 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4349,11 +4411,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 /* SourceFile */ ? node : node.body; - if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { + var body = node.kind === 246 /* SourceFile */ ? node : node.body; + if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { + if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { return true; } } @@ -4372,7 +4434,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8 /* StringLiteral */) { + if (node.name.kind === 9 /* StringLiteral */) { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -4382,14 +4444,21 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { + // if module was already merged with some function, class or non-const enum + // treat is a non-const-enum-only + node.symbol.constEnumOnlyModule = false; } else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -4418,7 +4487,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66 /* Identifier */) { + if (prop.name.kind !== 67 /* Identifier */) { continue; } var identifier = prop.name; @@ -4430,7 +4499,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ + var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4452,10 +4521,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4476,8 +4545,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4512,7 +4581,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 66 /* Identifier */) { + if (inStrictMode && node.expression.kind === 67 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4520,11 +4589,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66 /* Identifier */) { + if (name && name.kind === 67 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4568,7 +4637,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { + if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4612,17 +4681,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245 /* SourceFile */: - case 216 /* ModuleBlock */: + case 246 /* SourceFile */: + case 217 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4645,103 +4714,103 @@ var ts; var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkStrictModeIdentifier(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return checkStrictModeCatchClause(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkStrictModeWithStatement(node); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 135 /* Parameter */: + case 136 /* Parameter */: return bindParameter(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 141 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 142 /* GetAccessor */: + case 142 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 143 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return bindImportClause(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return bindExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return bindExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { @@ -4749,7 +4818,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 66 /* Identifier */) { + else if (node.expression.kind === 67 /* 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 */); } @@ -4774,7 +4843,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -4846,7 +4915,7 @@ 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 === 141 /* Constructor */ && + node.parent.kind === 142 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4912,6 +4981,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); @@ -4936,7 +5036,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245 /* SourceFile */) { + while (node && node.kind !== 246 /* SourceFile */) { node = node.parent; } return node; @@ -5031,7 +5131,7 @@ var ts; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -5048,15 +5148,15 @@ var ts; return current; } switch (current.kind) { - case 245 /* SourceFile */: - case 217 /* CaseBlock */: - case 241 /* CatchClause */: - case 215 /* ModuleDeclaration */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 246 /* SourceFile */: + case 218 /* CaseBlock */: + case 242 /* CatchClause */: + case 216 /* ModuleDeclaration */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return current; - case 189 /* Block */: + case 190 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5069,9 +5169,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 /* VariableDeclaration */ && + declaration.kind === 209 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 241 /* CatchClause */; + declaration.parent.kind === 242 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5101,7 +5201,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -5110,8 +5210,8 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + case 246 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file return ts.createTextSpan(0, 0); @@ -5119,16 +5219,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 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: errorNode = node.name; break; } @@ -5152,11 +5252,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 /* EnumDeclaration */ && isConst(node); + return node.kind === 215 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5171,14 +5271,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 209 /* VariableDeclarationList */) { + if (node && node.kind === 210 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190 /* VariableStatement */) { + if (node && node.kind === 191 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5193,25 +5293,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* 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 === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { - // e.g. (/** blah */ a, /** blah */ b); - // e.g.: ( - // /** blah */ a, - // /** blah */ b); - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { // True if the comment starts with '/**' but not if it is '/**/' return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -5222,40 +5315,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { return true; } switch (node.kind) { - case 114 /* AnyKeyword */: - case 125 /* NumberKeyword */: - case 127 /* StringKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 126 /* NumberKeyword */: + case 128 /* StringKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: return true; - case 100 /* VoidKeyword */: - return node.parent.kind !== 174 /* VoidExpression */; - case 8 /* StringLiteral */: + case 101 /* VoidKeyword */: + return node.parent.kind !== 175 /* VoidExpression */; + case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 135 /* Parameter */; - case 185 /* ExpressionWithTypeArguments */: + return node.parent.kind === 136 /* Parameter */; + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 66 /* Identifier */: + case 67 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 132 /* QualifiedName */: - case 163 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151 /* TypeQuery */) { + if (parent_1.kind === 152 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5264,38 +5357,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 (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return node === parent_1.constraint; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: return node === parent_1.type; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node === parent_1.type; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return node === parent_1.type; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return node === parent_1.type; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5309,23 +5402,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitor(node); - case 217 /* CaseBlock */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: + case 218 /* CaseBlock */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5335,18 +5428,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5354,7 +5447,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5373,14 +5466,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: return true; } } @@ -5388,41 +5481,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); + return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); + return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; + return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5450,7 +5557,7 @@ var ts; return undefined; } switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* 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 @@ -5465,9 +5572,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* 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; @@ -5478,23 +5585,23 @@ var ts; node = node.parent; } break; - case 171 /* ArrowFunction */: + case 172 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 215 /* ModuleDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 214 /* EnumDeclaration */: - case 245 /* SourceFile */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 216 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 215 /* EnumDeclaration */: + case 246 /* SourceFile */: return node; } } @@ -5506,7 +5613,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* 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 @@ -5521,9 +5628,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* 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; @@ -5534,19 +5641,19 @@ var ts; node = node.parent; } break; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node; } } @@ -5555,12 +5662,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: return node.typeName; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return node.expression; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: return node; } } @@ -5568,7 +5675,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5577,44 +5684,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // classes are valid targets return true; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 211 /* ClassDeclaration */; - case 135 /* Parameter */: + return node.parent.kind === 212 /* ClassDeclaration */; + case 136 /* 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 === 211 /* ClassDeclaration */; - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* 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 === 211 /* ClassDeclaration */; + return node.body && node.parent.kind === 212 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: if (node.decorators) { return true; } return false; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5625,10 +5732,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5640,93 +5747,93 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 9 /* RegularExpressionLiteral */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 186 /* AsExpression */: - case 168 /* TypeAssertionExpression */: - case 169 /* ParenthesizedExpression */: - case 170 /* FunctionExpression */: - case 183 /* ClassExpression */: - case 171 /* ArrowFunction */: - case 174 /* VoidExpression */: - case 172 /* DeleteExpression */: - case 173 /* TypeOfExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 180 /* TemplateExpression */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 184 /* OmittedExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 181 /* YieldExpression */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 187 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 170 /* ParenthesizedExpression */: + case 171 /* FunctionExpression */: + case 184 /* ClassExpression */: + case 172 /* ArrowFunction */: + case 175 /* VoidExpression */: + case 173 /* DeleteExpression */: + case 174 /* TypeOfExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 181 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 185 /* OmittedExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 182 /* YieldExpression */: return true; - case 132 /* QualifiedName */: - while (node.parent.kind === 132 /* QualifiedName */) { + case 133 /* QualifiedName */: + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 151 /* TypeQuery */; - case 66 /* Identifier */: - if (node.parent.kind === 151 /* TypeQuery */) { + return node.parent.kind === 152 /* TypeQuery */; + case 67 /* Identifier */: + if (node.parent.kind === 152 /* TypeQuery */) { return true; } // fall through - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 161 /* BindingElement */: return parent_2.initializer === node; - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 205 /* ThrowStatement */: - case 203 /* SwitchStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 206 /* ThrowStatement */: + case 204 /* SwitchStatement */: return parent_2.expression === node; - case 196 /* ForStatement */: + case 197 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forInStatement.expression === node; - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return node === parent_2.expression; - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return node === parent_2.expression; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return node === parent_2.expression; - case 136 /* Decorator */: + case 137 /* Decorator */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5851,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5753,20 +5860,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 229 /* ExternalModuleReference */) { + if (reference.kind === 230 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 225 /* ExportDeclaration */) { + if (node.kind === 226 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5774,15 +5881,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135 /* Parameter */: - return node.questionToken !== undefined; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - return node.questionToken !== undefined; - case 243 /* ShorthandPropertyAssignment */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 136 /* Parameter */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 244 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5790,9 +5895,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 /* JSDocFunctionType */ && + return node.kind === 259 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 260 /* JSDocConstructorType */; + node.parameters[0].type.kind === 261 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5806,26 +5911,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266 /* JSDocTypeTag */); + return getJSDocTag(node, 267 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265 /* JSDocReturnTag */); + return getJSDocTag(node, 266 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267 /* JSDocTemplateTag */); + return getJSDocTag(node, 268 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + if (parameter.name && parameter.name.kind === 67 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264 /* JSDocParameterTag */) { + if (t.kind === 265 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5844,12 +5949,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5858,19 +5963,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); + return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5885,34 +5990,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171 /* ArrowFunction */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 141 /* Constructor */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 227 /* ExportSpecifier */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 220 /* ImportClause */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 212 /* InterfaceDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 215 /* ModuleDeclaration */: - case 221 /* NamespaceImport */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 143 /* SetAccessor */: - case 243 /* ShorthandPropertyAssignment */: - case 213 /* TypeAliasDeclaration */: - case 134 /* TypeParameter */: - case 208 /* VariableDeclaration */: + case 172 /* ArrowFunction */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 142 /* Constructor */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 228 /* ExportSpecifier */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 221 /* ImportClause */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 213 /* InterfaceDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 216 /* ModuleDeclaration */: + case 222 /* NamespaceImport */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 144 /* SetAccessor */: + case 244 /* ShorthandPropertyAssignment */: + case 214 /* TypeAliasDeclaration */: + case 135 /* TypeParameter */: + case 209 /* VariableDeclaration */: return true; } return false; @@ -5920,25 +6025,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 207 /* DebuggerStatement */: - case 194 /* DoStatement */: - case 192 /* ExpressionStatement */: - case 191 /* EmptyStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 204 /* LabeledStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 95 /* ThrowKeyword */: - case 206 /* TryStatement */: - case 190 /* VariableStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 224 /* ExportAssignment */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 208 /* DebuggerStatement */: + case 195 /* DoStatement */: + case 193 /* ExpressionStatement */: + case 192 /* EmptyStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 205 /* LabeledStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 96 /* ThrowKeyword */: + case 207 /* TryStatement */: + case 191 /* VariableStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 225 /* ExportAssignment */: return true; default: return false; @@ -5947,13 +6052,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: return true; default: return false; @@ -5962,11 +6067,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { + if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5981,31 +6086,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 132 /* QualifiedName */) { + while (parent.kind === 133 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 151 /* TypeQuery */; + return parent.kind === 152 /* TypeQuery */; } return false; - case 160 /* BindingElement */: - case 223 /* ImportSpecifier */: + case 161 /* BindingElement */: + case 224 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6021,26 +6126,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 220 /* ImportClause */ && !!node.name || - node.kind === 221 /* NamespaceImport */ || - node.kind === 223 /* ImportSpecifier */ || - node.kind === 227 /* ExportSpecifier */ || - node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; + return node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 221 /* ImportClause */ && !!node.name || + node.kind === 222 /* NamespaceImport */ || + node.kind === 224 /* ImportSpecifier */ || + node.kind === 228 /* ExportSpecifier */ || + node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6109,11 +6214,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; + return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -6129,7 +6234,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 /* ComputedPropertyName */ && + declaration.name.kind === 134 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6139,14 +6244,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 133 /* ComputedPropertyName */) { + if (name.kind === 134 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6164,21 +6269,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 66 /* Identifier */ && node.text === "Symbol"; + return node.kind === 67 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112 /* AbstractKeyword */: - case 115 /* AsyncKeyword */: - case 71 /* ConstKeyword */: - case 119 /* DeclareKeyword */: - case 74 /* DefaultKeyword */: - case 79 /* ExportKeyword */: - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 113 /* AbstractKeyword */: + case 116 /* AsyncKeyword */: + case 72 /* ConstKeyword */: + case 120 /* DeclareKeyword */: + case 75 /* DefaultKeyword */: + case 80 /* ExportKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; } return false; @@ -6186,20 +6291,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135 /* Parameter */; + return root.kind === 136 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160 /* BindingElement */) { + while (node.kind === 161 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; + return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67 /* Identifier */) { + var clone_1 = createSynthesizedNode(67 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -6436,7 +6557,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6448,7 +6569,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); @@ -6465,10 +6586,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 143 /* SetAccessor */) { + else if (accessor.kind === 144 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6477,7 +6598,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) + if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6488,10 +6609,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 /* GetAccessor */ && !getAccessor) { + if (member.kind === 143 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 143 /* SetAccessor */ && !setAccessor) { + if (member.kind === 144 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6593,7 +6714,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -6624,16 +6745,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110 /* StaticKeyword */: return 128 /* Static */; - case 109 /* PublicKeyword */: return 16 /* Public */; - case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 107 /* PrivateKeyword */: return 32 /* Private */; - case 112 /* AbstractKeyword */: return 256 /* Abstract */; - case 79 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: return 2 /* Ambient */; - case 71 /* ConstKeyword */: return 32768 /* Const */; - case 74 /* DefaultKeyword */: return 1024 /* Default */; - case 115 /* AsyncKeyword */: return 512 /* Async */; + case 111 /* StaticKeyword */: return 128 /* Static */; + case 110 /* PublicKeyword */: return 16 /* Public */; + case 109 /* ProtectedKeyword */: return 64 /* Protected */; + case 108 /* PrivateKeyword */: return 32 /* Private */; + case 113 /* AbstractKeyword */: return 256 /* Abstract */; + case 80 /* ExportKeyword */: return 1 /* Export */; + case 120 /* DeclareKeyword */: return 2 /* Ambient */; + case 72 /* ConstKeyword */: return 32768 /* Const */; + case 75 /* DefaultKeyword */: return 1024 /* Default */; + case 116 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6641,29 +6762,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 166 /* NewExpression */: - case 165 /* CallExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 167 /* TaggedTemplateExpression */: - case 161 /* ArrayLiteralExpression */: - case 169 /* ParenthesizedExpression */: - case 162 /* ObjectLiteralExpression */: - case 183 /* ClassExpression */: - case 170 /* FunctionExpression */: - case 66 /* Identifier */: - case 9 /* RegularExpressionLiteral */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 180 /* TemplateExpression */: - case 81 /* FalseKeyword */: - case 90 /* NullKeyword */: - case 94 /* ThisKeyword */: - case 96 /* TrueKeyword */: - case 92 /* SuperKeyword */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 167 /* NewExpression */: + case 166 /* CallExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 168 /* TaggedTemplateExpression */: + case 162 /* ArrayLiteralExpression */: + case 170 /* ParenthesizedExpression */: + case 163 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 171 /* FunctionExpression */: + case 67 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 181 /* TemplateExpression */: + case 82 /* FalseKeyword */: + case 91 /* NullKeyword */: + case 95 /* ThisKeyword */: + case 97 /* TrueKeyword */: + case 93 /* SuperKeyword */: return true; } } @@ -6671,12 +6792,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; + return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 /* ExpressionWithTypeArguments */ && - node.parent.token === 80 /* ExtendsKeyword */ && + return node.kind === 186 /* ExpressionWithTypeArguments */ && + node.parent.token === 81 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6687,10 +6808,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66 /* Identifier */) { + if (node.kind === 67 /* Identifier */) { return true; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6698,10 +6819,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 162 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7004,13 +7136,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134 /* TypeParameter */) { + if (d && d.kind === 135 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { return current; } } @@ -7022,7 +7154,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269 /* Count */); + var nodeConstructors = new Array(270 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7067,20 +7199,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7089,24 +7221,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7117,290 +7249,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 154 /* TupleType */: + case 155 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209 /* VariableDeclarationList */: + case 210 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return visitNode(cbNode, node.label); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 238 /* CaseClause */: + case 239 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239 /* DefaultClause */: + case 240 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136 /* Decorator */: + case 137 /* Decorator */: return visitNode(cbNode, node.expression); - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* 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 212 /* InterfaceDeclaration */: + case 213 /* 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 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229 /* ExternalModuleReference */: + case 230 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235 /* JsxAttribute */: + case 236 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236 /* JsxSpreadAttribute */: + case 237 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 234 /* JsxClosingElement */: + case 235 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 246 /* JSDocTypeExpression */: + case 247 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 250 /* JSDocUnionType */: + case 251 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 251 /* JSDocTupleType */: + case 252 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 249 /* JSDocArrayType */: + case 250 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 253 /* JSDocNonNullableType */: + case 254 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 252 /* JSDocNullableType */: + case 253 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 254 /* JSDocRecordType */: + case 255 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 256 /* JSDocTypeReference */: + case 257 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257 /* JSDocOptionalType */: + case 258 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 258 /* JSDocFunctionType */: + case 259 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259 /* JSDocVariadicType */: + case 260 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 260 /* JSDocConstructorType */: + case 261 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 261 /* JSDocThisType */: + case 262 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordMember */: + case 256 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262 /* JSDocComment */: + case 263 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7408,7 +7540,7 @@ var ts; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); ts.parseTime += new Date().getTime() - start; return result; } @@ -7444,7 +7576,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; @@ -7595,9 +7727,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 190 /* VariableStatement */: - case 210 /* FunctionDeclaration */: - case 135 /* Parameter */: + case 191 /* VariableStatement */: + case 211 /* FunctionDeclaration */: + case 136 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7638,7 +7770,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245 /* SourceFile */, 0); + var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7792,6 +7924,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7823,35 +7958,38 @@ var ts; // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookAhead*/ true); } // Invokes the provided callback. If the callback returns something falsy, then it restores // the parser to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the parser state is not rolled back. The result // of invoking the callback is returned from this function. function tryParse(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookAhead*/ false); } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 111 /* YieldKeyword */ && inYieldContext()) { + if (token === 112 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 102 /* LastReservedWord */; + return token > 103 /* LastReservedWord */; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } // Report specific message if provided with one. Otherwise, report generic fallback message. @@ -7887,22 +8025,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 16 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(22 /* SemicolonToken */); + return parseExpected(23 /* SemicolonToken */); } } function createNode(kind, pos) { @@ -7950,16 +8088,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66 /* Identifier */); + var node = createNode(67 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 66 /* Identifier */) { + if (token !== 67 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -7969,56 +8107,56 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */; + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { - return parseLiteralNode(true); + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token === 18 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); } function parsePropertyName() { - return parsePropertyNameWorker(true); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); } function parseSimplePropertyName() { - return parsePropertyNameWorker(false); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); } function isSimplePropertyName() { - return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword(); } function parseComputedPropertyName() { // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(133 /* ComputedPropertyName */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(134 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71 /* ConstKeyword */) { + if (token === 72 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 78 /* EnumKeyword */; + return nextToken() === 79 /* EnumKeyword */; } - if (token === 79 /* ExportKeyword */) { + if (token === 80 /* ExportKeyword */) { nextToken(); - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -8028,14 +8166,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 /* OpenBracketToken */ - || token === 14 /* OpenBraceToken */ - || token === 36 /* AsteriskToken */ + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; + return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8053,9 +8191,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8063,19 +8201,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -8090,23 +8228,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token === 23 /* CommaToken */ || isStartOfType(); + return token === 24 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); case 13 /* JsxAttributes */: - return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -8119,8 +8257,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14 /* OpenBraceToken */); - if (nextToken() === 15 /* CloseBraceToken */) { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -8129,7 +8267,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; } return true; } @@ -8142,8 +8280,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 /* ImplementsKeyword */ || - token === 80 /* ExtendsKeyword */) { + if (token === 104 /* ImplementsKeyword */ || + token === 81 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8167,43 +8305,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token === 19 /* CloseBracketToken */; + return token === 20 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token === 18 /* CloseParenToken */ || token === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; case 20 /* HeritageClauses */: - return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; case 14 /* JsxChildren */: - return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -8221,7 +8359,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -8231,7 +8369,7 @@ var ts; function isInSomeParsingContext() { for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { return true; } } @@ -8245,7 +8383,7 @@ var ts; var result = []; result.pos = getNodePos(); while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { var element = parseListElement(kind, parseElement); result.push(element); continue; @@ -8385,20 +8523,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: - case 188 /* SemicolonClassElement */: + case 142 /* Constructor */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 189 /* SemicolonClassElement */: return true; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8407,8 +8545,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return true; } } @@ -8417,58 +8555,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 190 /* VariableStatement */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 192 /* ExpressionStatement */: - case 205 /* ThrowStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 191 /* EmptyStatement */: - case 206 /* TryStatement */: - case 204 /* LabeledStatement */: - case 194 /* DoStatement */: - case 207 /* DebuggerStatement */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 191 /* VariableStatement */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 193 /* ExpressionStatement */: + case 206 /* ThrowStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 192 /* EmptyStatement */: + case 207 /* TryStatement */: + case 205 /* LabeledStatement */: + case 195 /* DoStatement */: + case 208 /* DebuggerStatement */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244 /* EnumMember */; + return node.kind === 245 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145 /* ConstructSignature */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 137 /* PropertySignature */: - case 144 /* CallSignature */: + case 146 /* ConstructSignature */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 138 /* PropertySignature */: + case 145 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208 /* VariableDeclaration */) { + if (node.kind !== 209 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8489,7 +8627,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135 /* Parameter */) { + if (node.kind !== 136 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8544,10 +8682,10 @@ var ts; result.pos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -8556,13 +8694,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(23 /* CommaToken */); + parseExpected(24 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === 22 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimeter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8605,8 +8743,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20 /* DotToken */)) { - var node = createNode(132 /* QualifiedName */, entity.pos); + while (parseOptional(21 /* DotToken */)) { + var node = createNode(133 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8639,34 +8777,34 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180 /* TemplateExpression */); + var template = createNode(181 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187 /* TemplateSpan */); + var span = createNode(188 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -8690,7 +8828,7 @@ var ts; // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 7 /* NumericLiteral */ + if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536 /* OctalLiteral */; @@ -8699,31 +8837,31 @@ var ts; } // TYPES function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147 /* TypePredicate */, typeName.pos); + var node_1 = createNode(148 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148 /* TypeReference */, typeName.pos); + var node = createNode(149 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151 /* TypeQuery */); - parseExpected(98 /* TypeOfKeyword */); - node.exprName = parseEntityName(true); + var node = createNode(152 /* TypeQuery */); + parseExpected(99 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134 /* TypeParameter */); + var node = createNode(135 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(80 /* ExtendsKeyword */)) { + if (parseOptional(81 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8745,20 +8883,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(52 /* ColonToken */)) { - return token === 8 /* StringLiteral */ - ? parseLiteralNode(true) + if (parseOptional(53 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8767,10 +8905,10 @@ var ts; } } function parseParameter() { - var node = createNode(135 /* Parameter */); + var node = createNode(136 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -8785,9 +8923,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(51 /* QuestionToken */); + node.questionToken = parseOptionalToken(52 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8802,10 +8940,10 @@ var ts; return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); } function parseParameterInitializer() { - return parseInitializer(true); + return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -8830,7 +8968,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(16 /* OpenParenToken */)) { + if (parseExpected(17 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -8838,7 +8976,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -8853,7 +8991,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -8861,15 +8999,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145 /* ConstructSignature */) { - parseExpected(89 /* NewKeyword */); + if (kind === 146 /* ConstructSignature */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(52 /* ColonToken */, false, false, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18 /* OpenBracketToken */) { + if (token !== 19 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -8892,7 +9030,7 @@ var ts; // [] // nextToken(); - if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { return true; } if (ts.isModifier(token)) { @@ -8911,24 +9049,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 51 /* QuestionToken */) { + if (token !== 52 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146 /* IndexSignature */, fullStart); + var node = createNode(147 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8936,19 +9074,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(139 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(140 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(52 /* ColonToken */, false, false, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137 /* PropertySignature */, fullStart); + var property = createNode(138 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8958,9 +9096,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: return true; default: if (ts.isModifier(token)) { @@ -8980,29 +9118,29 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 /* OpenParenToken */ || - token === 24 /* LessThanToken */ || - token === 51 /* QuestionToken */ || - token === 52 /* ColonToken */ || + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 52 /* QuestionToken */ || + token === 53 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - return parseSignatureMember(144 /* CallSignature */); - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(145 /* CallSignature */); + case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145 /* ConstructSignature */); + return parseSignatureMember(146 /* ConstructSignature */); } // fall through. - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: return parsePropertyOrMethodSignature(); default: // Index declaration as allowed as a type member. But as per the grammar, @@ -9032,18 +9170,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(152 /* TypeLiteral */); + var node = createNode(153 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { members = createMissingList(); @@ -9051,48 +9189,48 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(155 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157 /* ParenthesizedType */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(158 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); node.type = parseType(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150 /* ConstructorType */) { - parseExpected(89 /* NewKeyword */); + if (kind === 151 /* ConstructorType */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 /* DotToken */ ? undefined : node; + return token === 21 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeQuery(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseTypeLiteral(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseTupleType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -9100,19 +9238,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 98 /* TypeOfKeyword */: - case 14 /* OpenBraceToken */: - case 18 /* OpenBracketToken */: - case 24 /* LessThanToken */: - case 89 /* NewKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 99 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 90 /* NewKeyword */: return true; - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -9122,13 +9260,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { - parseExpected(19 /* CloseBracketToken */); - var node = createNode(153 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(154 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9150,28 +9288,28 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); } function isStartOfFunctionType() { - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { return true; } - return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { // ( ) // ( ... return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9180,9 +9318,9 @@ var ts; // ( modifier id return true; } - if (token === 17 /* CloseParenToken */) { + if (token === 18 /* CloseParenToken */) { nextToken(); - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -9197,37 +9335,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149 /* FunctionType */); + return parseFunctionOrConstructorType(150 /* FunctionType */); } - if (token === 89 /* NewKeyword */) { - return parseFunctionOrConstructorType(150 /* ConstructorType */); + if (token === 90 /* NewKeyword */) { + return parseFunctionOrConstructorType(151 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52 /* ColonToken */) ? parseType() : undefined; + return parseOptional(53 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 89 /* NewKeyword */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 66 /* Identifier */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 90 /* NewKeyword */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 67 /* Identifier */: return true; default: return isIdentifier(); @@ -9238,18 +9376,18 @@ var ts; return true; } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 75 /* DeleteKeyword */: - case 98 /* TypeOfKeyword */: - case 100 /* VoidKeyword */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: - case 24 /* LessThanToken */: - case 116 /* AwaitKeyword */: - case 111 /* YieldKeyword */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 76 /* DeleteKeyword */: + case 99 /* TypeOfKeyword */: + case 101 /* VoidKeyword */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: + case 25 /* LessThanToken */: + case 117 /* AwaitKeyword */: + case 112 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9267,10 +9405,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token !== 14 /* OpenBraceToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && - token !== 53 /* AtToken */ && + return token !== 15 /* OpenBraceToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && + token !== 54 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9287,7 +9425,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -9296,7 +9434,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54 /* EqualsToken */) { + if (token !== 55 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9305,7 +9443,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -9313,7 +9451,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9485,11 @@ var ts; // Otherwise, we try to parse out the conditional expression bit. We want to allow any // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. - var expr = parseBinaryExpressionOrHigher(0); + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { + if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9367,7 +9505,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111 /* YieldKeyword */) { + if (token === 112 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9396,15 +9534,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181 /* YieldExpression */); + var node = createNode(182 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + (token === 37 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9415,16 +9553,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171 /* ArrowFunction */, identifier.pos); - var parameter = createNode(135 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172 /* ArrowFunction */, identifier.pos); + var parameter = createNode(136 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9438,7 +9576,7 @@ var ts; // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(true) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { // Didn't appear to actually be a parenthesized arrow function. Just bail out. @@ -9448,8 +9586,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -9459,10 +9597,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9472,28 +9610,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { return 0 /* False */; } } var first = token; var second = nextToken(); - if (first === 16 /* OpenParenToken */) { - if (second === 17 /* CloseParenToken */) { + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 33 /* EqualsGreaterThanToken */: - case 52 /* ColonToken */: - case 14 /* OpenBraceToken */: + case 34 /* EqualsGreaterThanToken */: + case 53 /* ColonToken */: + case 15 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -9505,12 +9643,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 18 /* OpenBracketToken */ || second === 14 /* OpenBraceToken */) { + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 21 /* DotDotDotToken */) { + if (second === 22 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -9523,7 +9661,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 52 /* ColonToken */) { + if (nextToken() === 53 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9531,7 +9669,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 24 /* LessThanToken */); + ts.Debug.assert(first === 25 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -9541,17 +9679,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80 /* ExtendsKeyword */) { + if (third === 81 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 54 /* EqualsToken */: - case 26 /* GreaterThanToken */: + case 55 /* EqualsToken */: + case 27 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 23 /* CommaToken */) { + else if (third === 24 /* CommaToken */) { return true; } return false; @@ -9566,10 +9704,10 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171 /* ArrowFunction */); + var node = createNode(172 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9579,7 +9717,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9592,19 +9730,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 34 /* EqualsGreaterThanToken */ && token !== 15 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, isAsync, false); + if (token === 15 /* OpenBraceToken */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token !== 22 /* SemicolonToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && + if (token !== 23 /* SemicolonToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9621,7 +9759,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, isAsync, true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } return isAsync ? doInAwaitContext(parseAssignmentExpressionOrHigher) @@ -9629,17 +9767,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(51 /* QuestionToken */); + var questionToken = parseOptionalToken(52 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); + node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9648,7 +9786,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; + return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9660,10 +9798,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 /* InKeyword */ && inDisallowInContext()) { + if (token === 88 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9684,46 +9822,46 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87 /* InKeyword */) { + if (inDisallowInContext() && token === 88 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return 1; - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return 2; - case 45 /* BarToken */: + case 46 /* BarToken */: return 3; - case 46 /* CaretToken */: + case 47 /* CaretToken */: return 4; - case 44 /* AmpersandToken */: + case 45 /* AmpersandToken */: return 5; - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: return 6; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 113 /* AsKeyword */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 114 /* AsKeyword */: return 7; - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 9; - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9731,45 +9869,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178 /* BinaryExpression */, left.pos); + var node = createNode(179 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186 /* AsExpression */, left.pos); + var node = createNode(187 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176 /* PrefixUnaryExpression */); + var node = createNode(177 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172 /* DeleteExpression */); + var node = createNode(173 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(173 /* TypeOfExpression */); + var node = createNode(174 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(174 /* VoidExpression */); + var node = createNode(175 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function isAwaitExpression() { - if (token === 116 /* AwaitKeyword */) { + if (token === 117 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9779,7 +9917,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175 /* AwaitExpression */); + var node = createNode(176 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9789,25 +9927,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 75 /* DeleteKeyword */: + case 76 /* DeleteKeyword */: return parseDeleteExpression(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseVoidExpression(); - case 24 /* LessThanToken */: + case 25 /* LessThanToken */: if (sourceFile.languageVariant !== 1 /* JSX */) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } // Fall through default: @@ -9817,8 +9955,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); + if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9857,7 +9995,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 92 /* SuperKeyword */ + var expression = token === 93 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9917,47 +10055,47 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* OpenBracketToken */) { return expression; } // 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(163 /* PropertyAccessExpression */, expression.pos); + var node = createNode(164 /* 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); + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232 /* JsxOpeningElement */) { - var node = createNode(230 /* JsxElement */, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233 /* JsxOpeningElement */) { + var node = createNode(231 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(233 /* JsxText */, scanner.getStartPos()); + var node = createNode(234 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233 /* JsxText */: + case 234 /* JsxText */: return parseJsxText(); - case 14 /* OpenBraceToken */: - return parseJsxExpression(); - case 24 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -9966,7 +10104,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { token = scanner.reScanJsxToken(); - if (token === 25 /* LessThanSlashToken */) { + if (token === 26 /* LessThanSlashToken */) { break; } else if (token === 1 /* EndOfFileToken */) { @@ -9979,19 +10117,29 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24 /* LessThanToken */); + parseExpected(25 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (parseOptional(26 /* GreaterThanToken */)) { - node = createNode(232 /* JsxOpeningElement */, fullStart); + if (token === 27 /* GreaterThanToken */) { + // Closing tag, so scan the immediately-following text with the JSX scanning instead + // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate + // scanning errors + node = createNode(233 /* JsxOpeningElement */, fullStart); + scanJsxText(); } else { - parseExpected(37 /* SlashToken */); - parseExpected(26 /* GreaterThanToken */); - node = createNode(231 /* JsxSelfClosingElement */, fullStart); + parseExpected(38 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(232 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10000,98 +10148,110 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20 /* DotToken */)) { + while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(132 /* QualifiedName */, elementName.pos); + var node = createNode(133 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237 /* JsxExpression */); - parseExpected(14 /* OpenBraceToken */); - if (token !== 15 /* CloseBraceToken */) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); } - parseExpected(15 /* CloseBraceToken */); + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235 /* JsxAttribute */); + var node = createNode(236 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { switch (token) { - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236 /* JsxSpreadAttribute */); - parseExpected(14 /* OpenBraceToken */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(237 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234 /* JsxClosingElement */); - parseExpected(25 /* LessThanSlashToken */); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); - parseExpected(26 /* GreaterThanToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168 /* TypeAssertionExpression */); - parseExpected(24 /* LessThanToken */); + var node = createNode(169 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); node.type = parseType(); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20 /* DotToken */); + var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } // 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(164 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { + var indexedAccess = createNode(165 /* 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. - if (token !== 19 /* CloseBracketToken */) { + if (token !== 20 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -10103,7 +10263,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -10112,15 +10272,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(165 /* CallExpression */, expression.pos); + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(165 /* CallExpression */, expression.pos); + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10130,17 +10290,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24 /* LessThanToken */)) { + if (!parseOptional(25 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(26 /* GreaterThanToken */)) { + if (!parseExpected(27 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -10152,32 +10312,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16 /* OpenParenToken */: // foo( + case 17 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 20 /* DotToken */: // foo. - case 17 /* CloseParenToken */: // foo) - case 19 /* CloseBracketToken */: // foo] - case 52 /* ColonToken */: // foo: - case 22 /* SemicolonToken */: // foo; - case 51 /* QuestionToken */: // foo? - case 29 /* EqualsEqualsToken */: // foo == - case 31 /* EqualsEqualsEqualsToken */: // foo === - case 30 /* ExclamationEqualsToken */: // foo != - case 32 /* ExclamationEqualsEqualsToken */: // foo !== - case 49 /* AmpersandAmpersandToken */: // foo && - case 50 /* BarBarToken */: // foo || - case 46 /* CaretToken */: // foo ^ - case 44 /* AmpersandToken */: // foo & - case 45 /* BarToken */: // foo | - case 15 /* CloseBraceToken */: // foo } + case 21 /* DotToken */: // foo. + case 18 /* CloseParenToken */: // foo) + case 20 /* CloseBracketToken */: // foo] + case 53 /* ColonToken */: // foo: + case 23 /* SemicolonToken */: // foo; + case 52 /* QuestionToken */: // foo? + case 30 /* EqualsEqualsToken */: // foo == + case 32 /* EqualsEqualsEqualsToken */: // foo === + case 31 /* ExclamationEqualsToken */: // foo != + case 33 /* ExclamationEqualsEqualsToken */: // foo !== + case 50 /* AmpersandAmpersandToken */: // foo && + case 51 /* BarBarToken */: // foo || + case 47 /* CaretToken */: // foo ^ + case 45 /* AmpersandToken */: // foo & + case 46 /* BarToken */: // foo | + case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 23 /* CommaToken */: // foo, - case 14 /* OpenBraceToken */: // foo { + case 24 /* CommaToken */: // foo, + case 15 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -10188,23 +10348,23 @@ var ts; } function parsePrimaryExpression() { switch (token) { - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return parseTokenNode(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedExpression(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10212,59 +10372,59 @@ var ts; break; } return parseFunctionExpression(); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassExpression(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionExpression(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseNewExpression(); - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 11 /* TemplateHead */: + case 12 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169 /* ParenthesizedExpression */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(170 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182 /* SpreadElementExpression */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(183 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161 /* ArrayLiteralExpression */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(162 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120 /* GetKeyword */)) { - return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(121 /* GetKeyword */)) { + return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(126 /* SetKeyword */)) { - return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(127 /* SetKeyword */)) { + return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10276,39 +10436,39 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // 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(243 /* ShorthandPropertyAssignment */, fullStart); + if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162 /* ObjectLiteralExpression */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(163 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); - parseExpected(15 /* CloseBraceToken */); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -10321,10 +10481,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170 /* FunctionExpression */); + var node = createNode(171 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); node.name = @@ -10332,8 +10492,8 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -10343,21 +10503,21 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166 /* NewExpression */); - parseExpected(89 /* NewKeyword */); + var node = createNode(167 /* NewExpression */); + parseExpected(90 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16 /* OpenParenToken */) { + if (node.typeArguments || token === 17 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189 /* Block */); - if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -10384,84 +10544,84 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191 /* EmptyStatement */); - parseExpected(22 /* SemicolonToken */); + var node = createNode(192 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(193 /* IfStatement */); - parseExpected(85 /* IfKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(194 /* IfStatement */); + parseExpected(86 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194 /* DoStatement */); - parseExpected(76 /* DoKeyword */); + var node = createNode(195 /* DoStatement */); + parseExpected(77 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(22 /* SemicolonToken */); + parseOptional(23 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195 /* WhileStatement */); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(196 /* WhileStatement */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83 /* ForKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(84 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); var initializer = undefined; - if (token !== 22 /* SemicolonToken */) { - if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(true); + if (token !== 23 /* SemicolonToken */) { + if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { initializer = disallowInAnd(parseExpression); } } var forOrForInOrForOfStatement; - if (parseOptional(87 /* InKeyword */)) { - var forInStatement = createNode(197 /* ForInStatement */, pos); + if (parseOptional(88 /* InKeyword */)) { + var forInStatement = createNode(198 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131 /* OfKeyword */)) { - var forOfStatement = createNode(198 /* ForOfStatement */, pos); + else if (parseOptional(132 /* OfKeyword */)) { + var forOfStatement = createNode(199 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196 /* ForStatement */, pos); + var forStatement = createNode(197 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(22 /* SemicolonToken */); - if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22 /* SemicolonToken */); - if (token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -10469,7 +10629,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); + parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10477,8 +10637,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201 /* ReturnStatement */); - parseExpected(91 /* ReturnKeyword */); + var node = createNode(202 /* ReturnStatement */); + parseExpected(92 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10486,42 +10646,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202 /* WithStatement */); - parseExpected(102 /* WithKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(203 /* WithStatement */); + parseExpected(103 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238 /* CaseClause */); - parseExpected(68 /* CaseKeyword */); + var node = createNode(239 /* CaseClause */); + parseExpected(69 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239 /* DefaultClause */); - parseExpected(74 /* DefaultKeyword */); - parseExpected(52 /* ColonToken */); + var node = createNode(240 /* DefaultClause */); + parseExpected(75 /* DefaultKeyword */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203 /* SwitchStatement */); - parseExpected(93 /* SwitchKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(204 /* SwitchStatement */); + parseExpected(94 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); - parseExpected(14 /* OpenBraceToken */); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -10533,39 +10693,39 @@ 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(205 /* ThrowStatement */); - parseExpected(95 /* ThrowKeyword */); + var node = createNode(206 /* ThrowStatement */); + parseExpected(96 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(206 /* TryStatement */); - parseExpected(97 /* TryKeyword */); - node.tryBlock = parseBlock(false); - node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; + var node = createNode(207 /* TryStatement */); + parseExpected(98 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 82 /* FinallyKeyword */) { - parseExpected(82 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false); + if (!node.catchClause || token === 83 /* FinallyKeyword */) { + parseExpected(83 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241 /* CatchClause */); - parseExpected(69 /* CatchKeyword */); - if (parseExpected(16 /* OpenParenToken */)) { + var result = createNode(242 /* CatchClause */); + parseExpected(70 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false); + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207 /* DebuggerStatement */); - parseExpected(73 /* DebuggerKeyword */); + var node = createNode(208 /* DebuggerStatement */); + parseExpected(74 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10575,21 +10735,21 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { - var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); + if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { + var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66 /* Identifier */; + return token >= 67 /* Identifier */; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -10597,21 +10757,21 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10634,36 +10794,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 79 /* ExportKeyword */: + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword(); + case 80 /* ExportKeyword */: nextToken(); - if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { + if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { return true; } continue; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: - case 112 /* AbstractKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: + case 113 /* AbstractKeyword */: nextToken(); continue; default: @@ -10676,47 +10836,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53 /* AtToken */: - case 22 /* SemicolonToken */: - case 14 /* OpenBraceToken */: - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 85 /* IfKeyword */: - case 76 /* DoKeyword */: - case 101 /* WhileKeyword */: - case 83 /* ForKeyword */: - case 72 /* ContinueKeyword */: - case 67 /* BreakKeyword */: - case 91 /* ReturnKeyword */: - case 102 /* WithKeyword */: - case 93 /* SwitchKeyword */: - case 95 /* ThrowKeyword */: - case 97 /* TryKeyword */: - case 73 /* DebuggerKeyword */: + case 54 /* AtToken */: + case 23 /* SemicolonToken */: + case 15 /* OpenBraceToken */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 86 /* IfKeyword */: + case 77 /* DoKeyword */: + case 102 /* WhileKeyword */: + case 84 /* ForKeyword */: + case 73 /* ContinueKeyword */: + case 68 /* BreakKeyword */: + case 92 /* ReturnKeyword */: + case 103 /* WithKeyword */: + case 94 /* SwitchKeyword */: + case 96 /* ThrowKeyword */: + case 98 /* TryKeyword */: + case 74 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return true; - case 71 /* ConstKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: + case 72 /* ConstKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: - case 104 /* InterfaceKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 129 /* TypeKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: + case 105 /* InterfaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 130 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10726,7 +10886,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -10735,65 +10895,65 @@ var ts; } function parseStatement() { switch (token) { - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: return parseEmptyStatement(); - case 14 /* OpenBraceToken */: - return parseBlock(false); - case 99 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105 /* LetKeyword */: + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 100 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 106 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 84 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 85 /* IfKeyword */: + case 85 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 71 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 86 /* IfKeyword */: return parseIfStatement(); - case 76 /* DoKeyword */: + case 77 /* DoKeyword */: return parseDoStatement(); - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return parseWhileStatement(); - case 83 /* ForKeyword */: + case 84 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 72 /* ContinueKeyword */: - return parseBreakOrContinueStatement(199 /* ContinueStatement */); - case 67 /* BreakKeyword */: - return parseBreakOrContinueStatement(200 /* BreakStatement */); - case 91 /* ReturnKeyword */: + case 73 /* ContinueKeyword */: + return parseBreakOrContinueStatement(200 /* ContinueStatement */); + case 68 /* BreakKeyword */: + return parseBreakOrContinueStatement(201 /* BreakStatement */); + case 92 /* ReturnKeyword */: return parseReturnStatement(); - case 102 /* WithKeyword */: + case 103 /* WithKeyword */: return parseWithStatement(); - case 93 /* SwitchKeyword */: + case 94 /* SwitchKeyword */: return parseSwitchStatement(); - case 95 /* ThrowKeyword */: + case 96 /* ThrowKeyword */: return parseThrowStatement(); - case 97 /* TryKeyword */: + case 98 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return parseTryStatement(); - case 73 /* DebuggerKeyword */: + case 74 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 53 /* AtToken */: + case 54 /* AtToken */: return parseDeclaration(); - case 115 /* AsyncKeyword */: - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 119 /* DeclareKeyword */: - case 71 /* ConstKeyword */: - case 78 /* EnumKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 109 /* PublicKeyword */: - case 112 /* AbstractKeyword */: - case 110 /* StaticKeyword */: + case 116 /* AsyncKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 120 /* DeclareKeyword */: + case 72 /* ConstKeyword */: + case 79 /* EnumKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 113 /* AbstractKeyword */: + case 111 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10806,35 +10966,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104 /* InterfaceKeyword */: + case 105 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129 /* TypeKeyword */: + case 130 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78 /* EnumKeyword */: + case 79 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: nextToken(); - return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? + return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10844,86 +11004,86 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { - if (token === 23 /* CommaToken */) { - return createNode(184 /* OmittedExpression */); + if (token === 24 /* CommaToken */) { + return createNode(185 /* OmittedExpression */); } - var node = createNode(160 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + var node = createNode(161 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160 /* BindingElement */); + var node = createNode(161 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52 /* ColonToken */) { + if (tokenIsIdentifier && token !== 53 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158 /* ObjectBindingPattern */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(159 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159 /* ArrayBindingPattern */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(160 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208 /* VariableDeclaration */); + var node = createNode(209 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); + node.initializer = parseInitializer(/*inParameter*/ false); } return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209 /* VariableDeclarationList */); + var node = createNode(210 /* VariableDeclarationList */); switch (token) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -10939,7 +11099,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 === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10951,40 +11111,40 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190 /* VariableStatement */, fullStart); + var node = createNode(191 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210 /* FunctionDeclaration */, fullStart); + var node = createNode(211 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141 /* Constructor */, pos); + var node = createNode(142 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118 /* ConstructorKeyword */); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + parseExpected(119 /* ConstructorKeyword */); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140 /* MethodDeclaration */, fullStart); + var method = createNode(141 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10992,12 +11152,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138 /* PropertyDeclaration */, fullStart); + var property = createNode(139 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11019,12 +11179,12 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -11032,23 +11192,23 @@ var ts; } } function parseNonParameterInitializer() { - return parseInitializer(false); + return parseInitializer(/*inParameter*/ false); } function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; default: return false; @@ -11056,7 +11216,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53 /* AtToken */) { + if (token === 54 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11073,7 +11233,7 @@ var ts; } nextToken(); } - if (token === 36 /* AsteriskToken */) { + if (token === 37 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -11083,23 +11243,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return true; } // 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 === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token) { - case 16 /* OpenParenToken */: // Method declaration - case 24 /* LessThanToken */: // Generic Method declaration - case 52 /* ColonToken */: // Type Annotation for declaration - case 54 /* EqualsToken */: // Initializer for declaration - case 51 /* QuestionToken */: + case 17 /* OpenParenToken */: // Method declaration + case 25 /* LessThanToken */: // Generic Method declaration + case 53 /* ColonToken */: // Type Annotation for declaration + case 55 /* EqualsToken */: // Initializer for declaration + case 52 /* QuestionToken */: return true; default: // Covers @@ -11116,14 +11276,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53 /* AtToken */)) { + if (!parseOptional(54 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136 /* Decorator */, decoratorStart); + var decorator = createNode(137 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11157,7 +11317,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11171,8 +11331,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22 /* SemicolonToken */) { - var result = createNode(188 /* SemicolonClassElement */); + if (token === 23 /* SemicolonToken */) { + var result = createNode(189 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11183,7 +11343,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11192,16 +11352,16 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */ || - token === 36 /* AsteriskToken */ || - token === 18 /* OpenBracketToken */) { + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); + var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -11210,24 +11370,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 183 /* ClassExpression */); + /*modifiers*/ undefined, 184 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70 /* ClassKeyword */); + parseExpected(71 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11246,8 +11406,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { - var node = createNode(240 /* HeritageClause */); + if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { + var node = createNode(241 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11256,38 +11416,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185 /* ExpressionWithTypeArguments */); + var node = createNode(186 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212 /* InterfaceDeclaration */, fullStart); + var node = createNode(213 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104 /* InterfaceKeyword */); + parseExpected(105 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* TypeAliasDeclaration */, fullStart); + var node = createNode(214 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129 /* TypeKeyword */); + parseExpected(130 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11297,20 +11457,20 @@ 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(244 /* EnumMember */, scanner.getStartPos()); + var node = createNode(245 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* EnumDeclaration */, fullStart); + var node = createNode(215 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78 /* EnumKeyword */); + parseExpected(79 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11318,10 +11478,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(14 /* OpenBraceToken */)) { + var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -11329,84 +11489,84 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + node.name = parseLiteralNode(/*internName*/ true); node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123 /* NamespaceKeyword */)) { + if (parseOptional(124 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(122 /* ModuleKeyword */); - if (token === 8 /* StringLiteral */) { + parseExpected(123 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 /* RequireKeyword */ && + return token === 125 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16 /* OpenParenToken */; + return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 37 /* SlashToken */; + return nextToken() === 38 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 /* CommaToken */ || - token === 130 /* FromKeyword */; + return token === 24 /* CommaToken */ || + token === 131 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86 /* ImportKeyword */); + parseExpected(87 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */) { + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130 /* FromKeyword */); + parseExpected(131 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11419,7 +11579,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220 /* ImportClause */, fullStart); + var importClause = createNode(221 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11428,22 +11588,22 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); + parseOptional(24 /* CommaToken */)) { + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); } return finishNode(importClause); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(229 /* ExternalModuleReference */); - parseExpected(124 /* RequireKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(230 /* ExternalModuleReference */); + parseExpected(125 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -11453,7 +11613,7 @@ var ts; var result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 8 /* StringLiteral */) { + if (result.kind === 9 /* StringLiteral */) { internIdentifier(result.text); } return result; @@ -11461,9 +11621,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(221 /* NamespaceImport */); - parseExpected(36 /* AsteriskToken */); - parseExpected(113 /* AsKeyword */); + var namespaceImport = createNode(222 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(114 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11476,14 +11636,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227 /* ExportSpecifier */); + return parseImportOrExportSpecifier(228 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223 /* ImportSpecifier */); + return parseImportOrExportSpecifier(224 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11497,9 +11657,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(113 /* AsKeyword */); + parseExpected(114 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11508,27 +11668,27 @@ var ts; else { node.name = identifierName; } - if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 224 /* 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(225 /* ExportDeclaration */, fullStart); + var node = createNode(226 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36 /* AsteriskToken */)) { - parseExpected(130 /* FromKeyword */); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(130 /* FromKeyword */); + if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11536,21 +11696,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224 /* ExportAssignment */, fullStart); + var node = createNode(225 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(74 /* DefaultKeyword */); + parseExpected(75 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11609,10 +11769,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ - || node.kind === 219 /* ImportDeclaration */ - || node.kind === 224 /* ExportAssignment */ - || node.kind === 225 /* ExportDeclaration */ + || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ + || node.kind === 220 /* ImportDeclaration */ + || node.kind === 225 /* ExportAssignment */ + || node.kind === 226 /* ExportDeclaration */ ? node : undefined; }); @@ -11657,23 +11817,23 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36 /* AsteriskToken */: - case 51 /* QuestionToken */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 47 /* ExclamationToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 21 /* DotDotDotToken */: - case 89 /* NewKeyword */: - case 94 /* ThisKeyword */: + case 37 /* AsteriskToken */: + case 52 /* QuestionToken */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 48 /* ExclamationToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 22 /* DotDotDotToken */: + case 90 /* NewKeyword */: + case 95 /* ThisKeyword */: return true; } return isIdentifierOrKeyword(); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11687,23 +11847,23 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(246 /* JSDocTypeExpression */); - parseExpected(14 /* OpenBraceToken */); + var result = createNode(247 /* JSDocTypeExpression */); + parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45 /* BarToken */) { - var unionType = createNode(250 /* JSDocUnionType */, type.pos); + if (token === 46 /* BarToken */) { + var unionType = createNode(251 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54 /* EqualsToken */) { - var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); + if (token === 55 /* EqualsToken */) { + var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11713,21 +11873,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(249 /* JSDocArrayType */, type.pos); + if (token === 19 /* OpenBracketToken */) { + var arrayType = createNode(250 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 51 /* QuestionToken */) { - var nullableType = createNode(252 /* JSDocNullableType */, type.pos); + else if (token === 52 /* QuestionToken */) { + var nullableType = createNode(253 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47 /* ExclamationToken */) { - var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); + else if (token === 48 /* ExclamationToken */) { + var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11740,85 +11900,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36 /* AsteriskToken */: + case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 51 /* QuestionToken */: + case 52 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseJSDocUnionType(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 21 /* DotDotDotToken */: + case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseJSDocConstructorType(); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return parseJSDocThisType(); - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261 /* JSDocThisType */); + var result = createNode(262 /* JSDocThisType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260 /* JSDocConstructorType */); + var result = createNode(261 /* JSDocConstructorType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259 /* JSDocVariadicType */); + var result = createNode(260 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258 /* JSDocFunctionType */); + var result = createNode(259 /* JSDocFunctionType */); nextToken(); - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17 /* CloseParenToken */); - if (token === 52 /* ColonToken */) { + parseExpected(18 /* CloseParenToken */); + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135 /* Parameter */); + var parameter = createNode(136 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257 /* JSDocOptionalType */, type.pos); + var result = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256 /* JSDocTypeReference */); + var result = createNode(257 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(20 /* DotToken */)) { - if (token === 24 /* LessThanToken */) { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -11834,7 +11994,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11845,40 +12005,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132 /* QualifiedName */, left.pos); + var result = createNode(133 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254 /* JSDocRecordType */); + var result = createNode(255 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255 /* JSDocRecordMember */); + var result = createNode(256 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 52 /* ColonToken */) { + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253 /* JSDocNonNullableType */); + var result = createNode(254 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251 /* JSDocTupleType */); + var result = createNode(252 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -11888,10 +12048,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250 /* JSDocUnionType */); + var result = createNode(251 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -11899,14 +12059,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45 /* BarToken */)) { + while (parseOptional(46 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247 /* JSDocAllType */); + var result = createNode(248 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11923,24 +12083,24 @@ var ts; // Foo // Foo(?= // (?| - if (token === 23 /* CommaToken */ || - token === 15 /* CloseBraceToken */ || - token === 17 /* CloseParenToken */ || - token === 26 /* GreaterThanToken */ || - token === 54 /* EqualsToken */ || - token === 45 /* BarToken */) { - var result = createNode(248 /* JSDocUnknownType */, pos); + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 55 /* EqualsToken */ || + token === 46 /* BarToken */) { + var result = createNode(249 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(252 /* JSDocNullableType */, pos); + var result = createNode(253 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; @@ -12021,7 +12181,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262 /* JSDocComment */, start); + var result = createNode(263 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12032,7 +12192,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(53 /* AtToken */, pos - 1); + var atToken = createNode(54 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12058,7 +12218,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263 /* JSDocTag */, atToken.pos); + var result = createNode(264 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12110,7 +12270,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264 /* JSDocParameterTag */, atToken.pos); + var result = createNode(265 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12120,27 +12280,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(265 /* JSDocReturnTag */, atToken.pos); + var result = createNode(266 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocTypeTag */, atToken.pos); + var result = createNode(267 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12153,7 +12313,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12164,7 +12324,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12185,7 +12345,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66 /* Identifier */, startPos); + var result = createNode(67 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12205,7 +12365,7 @@ var ts; if (sourceFile.statements.length === 0) { // If we don't have any statements in the current source file, then there's no real // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); } // Make sure we're not trying to incrementally update a source file more than once. Once // we do an update the original source file is considered unusbale from that point onwards. @@ -12261,7 +12421,7 @@ var ts; // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12274,7 +12434,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12466,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: - case 66 /* Identifier */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 67 /* Identifier */: return true; } return false; @@ -12400,7 +12560,7 @@ var ts; if (child.pos > changeRangeOldEnd) { // Node is entirely past the change range. We need to move both its pos and // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12424,7 +12584,7 @@ var ts; if (array.pos > changeRangeOldEnd) { // Array is entirely after the change range. We need to move it, and move any of // its children. - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12717,17 +12877,20 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -12744,7 +12907,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12752,16 +12916,19 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -12806,6 +12973,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +12995,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13008,15 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -12984,10 +13161,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245 /* SourceFile */); + return ts.getAncestor(node, 246 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13013,7 +13190,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -13044,13 +13221,13 @@ var ts; } } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 /* SourceFile */ || - (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 246 /* SourceFile */ || + (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13064,7 +13241,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13078,13 +13255,13 @@ var ts; break loop; } break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* 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 @@ -13101,9 +13278,9 @@ var ts; } } break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* 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 @@ -13114,7 +13291,7 @@ var ts; } break loop; } - if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13130,9 +13307,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* 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); @@ -13140,19 +13317,19 @@ var ts; } } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13165,7 +13342,7 @@ var ts; } } break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13174,7 +13351,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 === 135 /* Parameter */) { + if (location.parent && location.parent.kind === 136 /* Parameter */) { location = location.parent; } // @@ -13209,7 +13386,18 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2 /* BlockScopedVariable */) { + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -13230,16 +13418,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, 208 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 197 /* 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 === 198 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -13266,10 +13454,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 219 /* ImportDeclaration */) { + while (node && node.kind !== 220 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13279,7 +13467,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13386,17 +13574,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return getTargetOfImportClause(node); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 223 /* ImportSpecifier */: + case 224 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13441,11 +13629,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224 /* ExportAssignment */) { + if (node.kind === 225 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 227 /* ExportSpecifier */) { + else if (node.kind === 228 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13458,7 +13646,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13467,17 +13655,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { + if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* 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 === 218 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13490,16 +13678,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { - var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { + var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13524,7 +13712,7 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -13532,29 +13720,18 @@ var ts; // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -13662,7 +13839,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13732,17 +13909,17 @@ var ts; } } switch (location_1.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13783,7 +13960,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13820,7 +13997,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13836,7 +14013,7 @@ var ts; var meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -13893,8 +14070,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13930,12 +14107,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 151 /* TypeQuery */) { + if (entityName.parent.kind === 152 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || - entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || + entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13945,7 +14122,7 @@ var ts; meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, @@ -13990,17 +14167,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157 /* ParenthesizedType */) { + while (node.kind === 158 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 214 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -14009,10 +14184,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return "(Anonymous class)"; - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14042,7 +14217,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14273,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 4194431 /* Intrinsic */) { + if (type.flags & 16777343 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -14126,23 +14301,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23 /* CommaToken */) { + if (delimiter !== 24 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -14152,22 +14327,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); } if (pos < end) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); writeType(typeArguments[pos++], 0 /* None */); while (pos < end) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 18 /* OpenBracketToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -14188,7 +14363,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } } } @@ -14196,17 +14371,17 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 23 /* CommaToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -14228,7 +14403,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14427,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; + return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14262,7 +14437,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98 /* TypeOfKeyword */); + writeKeyword(writer, 99 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14280,76 +14455,76 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14 /* OpenBraceToken */); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 127 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 128 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { // [x: number]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 125 /* NumberKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 126 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -14361,27 +14536,27 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -14395,7 +14570,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80 /* ExtendsKeyword */); + writeKeyword(writer, 81 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14403,67 +14578,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 33 /* EqualsGreaterThanToken */); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121 /* IsKeyword */); + writeKeyword(writer, 122 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14485,15 +14660,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -14502,12 +14674,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215 /* ModuleDeclaration */) { - if (node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 216 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 245 /* SourceFile */) { + else if (node.kind === 246 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -14556,70 +14728,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160 /* BindingElement */: + case 161 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 208 /* VariableDeclaration */: + case 209 /* 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 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 210 /* FunctionDeclaration */: - case 214 /* EnumDeclaration */: - case 218 /* ImportEqualsDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 215 /* EnumDeclaration */: + case 219 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 140 /* 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 141 /* Constructor */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: - case 135 /* Parameter */: - case 216 /* ModuleBlock */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: - case 148 /* TypeReference */: - case 153 /* ArrayType */: - case 154 /* TupleType */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 157 /* ParenthesizedType */: + case 142 /* Constructor */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: + case 136 /* Parameter */: + case 217 /* ModuleBlock */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: + case 149 /* TypeReference */: + case 154 /* ArrayType */: + case 155 /* TupleType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 158 /* 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 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: return false; // Type parameters are always visible - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: // Source file is always visible - case 245 /* SourceFile */: + case 246 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14635,11 +14807,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } var result = []; if (exportSymbol) { @@ -14663,40 +14838,71 @@ 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); + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } // 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(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14732,7 +14938,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -14749,11 +14955,8 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -14779,10 +14982,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 === 197 /* ForInStatement */) { + if (declaration.parent.parent.kind === 198 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 199 /* 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, @@ -14796,11 +14999,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* 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 === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); + if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14816,9 +15019,13 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } // No type specified and nothing can be inferred return undefined; } @@ -14851,7 +15058,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -14874,7 +15081,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 === 158 /* ObjectBindingPattern */ + return pattern.kind === 159 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -14896,19 +15103,14 @@ 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 !== 242 /* 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 - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14923,18 +15125,18 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241 /* CatchClause */) { + if (declaration.parent.kind === 242 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 224 /* ExportAssignment */) { + if (declaration.kind === 225 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); if (!popTypeResolution()) { if (symbol.valueDeclaration.type) { // Variable has type annotation that circularly references the variable itself @@ -14955,7 +15157,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -14968,11 +15170,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15001,7 +15203,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* 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)); } } @@ -15101,9 +15303,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || - node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { + if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || + node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15113,7 +15315,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15122,8 +15324,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || - node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || + node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15166,7 +15368,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -15234,7 +15436,7 @@ var ts; return; } if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } type.resolvedBaseTypes = [baseType]; @@ -15243,7 +15445,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15253,7 +15455,7 @@ var ts; type.resolvedBaseTypes.push(baseType); } else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); } } else { @@ -15289,10 +15491,10 @@ var ts; if (!links.declaredType) { // 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)) { + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15325,7 +15527,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15492,43 +15694,70 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; } - // If the lists of call or construct signatures in the given types are all identical except for return types, - // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the - // return types of the corresponding signatures in each resulting signature. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; } - } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } } + return [signature]; } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } } return result; } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } function getUnionIndexType(types, kind) { var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { @@ -15679,9 +15908,6 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* Union */) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512 /* TypeParameter */) { do { type = getConstraintOfTypeParameter(type); @@ -15699,7 +15925,7 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 4194304 /* ESSymbol */) { + else if (type.flags & 16777216 /* ESSymbol */) { type = globalESSymbolType; } return type; @@ -15784,6 +16010,29 @@ var ts; } return undefined; } + // Check if a property with the given name is known anywhere in the given type. In an object + // type, a property is considered known if the object type is empty, if it has any index + // signatures, or if the property is actually declared in the type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); @@ -15791,8 +16040,10 @@ var ts; } return emptyArray; } - // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - // maps primitive types and type parameters are to their apparent types. + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } @@ -15845,12 +16096,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15859,14 +16120,18 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8 /* StringLiteral */) { + if (param.type && param.type.kind === 9 /* StringLiteral */) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -15878,7 +16143,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147 /* TypePredicate */) { + if (declaration.type.kind === 148 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15890,8 +16155,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 === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); + if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15909,19 +16174,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* 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). @@ -15938,7 +16203,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16263,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 === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16012,7 +16277,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16041,13 +16306,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -16066,22 +16331,23 @@ var ts; return result; } } - // This function is used to propagate widening flags when creating new object types references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type - // of an object literal (since those types have widening related information we need to track). - function getWideningFlagsOfTypes(types) { + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728 /* RequiresWidening */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16100,16 +16366,16 @@ 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 === 134 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { + if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // Type parameters declared in a particular type parameter list @@ -16138,7 +16404,7 @@ var ts; var typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -16193,7 +16459,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16225,9 +16491,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: return declaration; } } @@ -16261,14 +16527,14 @@ var ts; } function tryGetGlobalType(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -16310,7 +16576,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -16338,20 +16604,71 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of + // a target type if the the two are identical, with the exception that the source type may have null or + // undefined in places where the target type doesn't. This is by design an asymmetric relationship. + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) { + return true; + } + if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -16374,29 +16691,26 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag - // is true when creating a union type from a type node and when instantiating a union type. In both of those - // cases subtype reduction has to be deferred to properly support recursive union types. For example, a - // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration. - function getUnionType(types, noSubtypeReduction) { + // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate + // based on the structure of the types unless the noDeduplication flag is true, which is the case when + // creating a union type from a type node and when instantiating a union type. In both of those cases, + // structural deduplication has to be deferred to properly support recursive union types. For example, + // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384 /* Union */); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -16404,37 +16718,19 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer - // to process and look strange in quick info and error messages. Semantically there is no difference between the - // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the - // type itself. - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); } return links.resolvedType; } - // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution @@ -16454,7 +16750,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -16491,47 +16787,47 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114 /* AnyKeyword */: + case 115 /* AnyKeyword */: return anyType; - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: return stringType; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: return numberType; - case 117 /* BooleanKeyword */: + case 118 /* BooleanKeyword */: return booleanType; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: return esSymbolType; - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return voidType; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return getTypeFromTypeReference(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return booleanType; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 155 /* UnionType */: + case 156 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* 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 66 /* Identifier */: - case 132 /* QualifiedName */: - var symbol = getSymbolInfo(node); + case 67 /* Identifier */: + case 133 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -16590,7 +16886,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -16599,6 +16895,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16689,7 +16987,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -16700,27 +16998,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 !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178 /* BinaryExpression */: - return node.operatorToken.kind === 50 /* BarBarToken */ && + case 179 /* BinaryExpression */: + return node.operatorToken.kind === 51 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16744,16 +17042,16 @@ var ts; } // TYPE CHECKING function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); @@ -16764,7 +17062,7 @@ var ts; function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -16809,6 +17107,15 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -16818,110 +17125,140 @@ var ts; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1 /* True */; - if (source === undefinedType) + if (source === numberType && target.flags & 128 /* Enum */) return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "each" checks on both sides because there may be nested "some" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - // Even if relationship doesn't hold for unions, type parameters, or generic type references, - // it may hold in a structural comparison. - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // Identity relation does not use apparent type - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { - // We clear the errors first because the following check often gives a better error than - // the union or intersection comparison above if it is applicable. - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, undefined, 128 /* UseFullyQualifiedType */); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0 /* False */; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; @@ -16992,31 +17329,18 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1 /* True */; - if (!(constraint && constraint.flags & 512 /* TypeParameter */)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0 /* False */; } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); } // Determine if two object types are related by structure. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. @@ -17211,26 +17535,20 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - var sourceSig = sourceSignatures[0]; - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -17255,6 +17573,33 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -17345,7 +17690,7 @@ var ts; } var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; } @@ -17358,7 +17703,7 @@ var ts; return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceType = getIndexTypeOfType(source, 0 /* String */); if (!sourceType) { if (reportErrors) { @@ -17382,7 +17727,7 @@ var ts; return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceStringType = getIndexTypeOfType(source, 0 /* String */); var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); if (!(sourceStringType || sourceNumberType)) { @@ -17469,14 +17814,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0 /* False */; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } } var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { @@ -17498,16 +17847,18 @@ var ts; // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0 /* False */; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -17573,6 +17924,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -17600,7 +17968,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } @@ -17655,7 +18023,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -17669,22 +18037,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135 /* Parameter */: + case 136 /* 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 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -17697,7 +18065,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17734,7 +18102,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -17758,11 +18128,16 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -17793,6 +18168,14 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; @@ -17959,10 +18342,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 151 /* TypeQuery */: + case 152 /* TypeQuery */: return true; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: node = node.parent; continue; default: @@ -18008,12 +18391,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { + if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { var n = node.left; - while (n.kind === 169 /* ParenthesizedExpression */) { + while (n.kind === 170 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18027,96 +18410,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 176 /* PrefixUnaryExpression */: - case 172 /* DeleteExpression */: - case 175 /* AwaitExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 177 /* PostfixUnaryExpression */: - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 189 /* Block */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: - case 237 /* JsxExpression */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 177 /* PrefixUnaryExpression */: + case 173 /* DeleteExpression */: + case 176 /* AwaitExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 178 /* PostfixUnaryExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 190 /* Block */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: + case 238 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - // Resolve location from top down towards node if it is a context sensitive expression - // That helps in making sure not assigning types as any when resolved out of order - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - // Get the narrowed type of symbol at given location instead of just getting - // the type of the symbol. - // eg. - // function foo(a: string | number) { - // if (typeof a === "string") { - // a/**/ - // } - // } - // getTypeOfSymbol for a would return type of parameter symbol string | number - // Unless we provide location /**/, checker wouldn't know how to narrow the type - // By using getNarrowedTypeOfSymbol would return string since it would be able to narrow - // it by typeguard in the if true condition - return getNarrowedTypeOfSymbol(symbol, node); - } // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); @@ -18128,37 +18475,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193 /* IfStatement */: + case 194 /* 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); + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 179 /* ConditionalExpression */: + case 180 /* 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); + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, true); + if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 50 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, false); + else if (node.operatorToken.kind === 51 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 245 /* SourceFile */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: + case 246 /* SourceFile */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18175,23 +18522,23 @@ 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 !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, - /*isOfTypeKind*/ true, false); + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Check was for a primitive type, return that primitive type if it is a subtype if (isTypeSubtypeOf(typeInfo.type, type)) { @@ -18199,12 +18546,12 @@ var ts; } // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is // union of enum types and other types. - return removeTypesFromUnionType(type, typeInfo.flags, false, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); } else { // Assumed result is false. If check was for a primitive type, remove that primitive type if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Otherwise we don't have enough information to do anything. return type; @@ -18213,14 +18560,14 @@ var ts; function narrowTypeByAnd(type, expr, assumeTrue) { if (assumeTrue) { // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, true), expr.right, true); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); } else { // The assumed result is false. This means either the first operand was false, or the first operand was true // and the second operand was false. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) ]); } } @@ -18229,18 +18576,18 @@ var ts; // The assumed result is true. This means either the first operand was true, or the first operand was false // and the second operand was true. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) ]); } else { // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, false), expr.right, false); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); } } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18276,13 +18623,17 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check if (originalType.flags & 16384 /* Union */) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; } return originalType; } @@ -18308,27 +18659,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165 /* CallExpression */: + case 166 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49 /* AmpersandAmpersandToken */) { + else if (operator === 50 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88 /* InstanceOfKeyword */) { + else if (operator === 89 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176 /* PrefixUnaryExpression */: - if (expr.operator === 47 /* ExclamationToken */) { + case 177 /* PrefixUnaryExpression */: + if (expr.operator === 48 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18346,7 +18697,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171 /* ArrowFunction */) { + if (container.kind === 172 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18377,7 +18728,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18386,19 +18737,19 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 209 /* VariableDeclarationList */) { + while (container.kind !== 210 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 190 /* VariableStatement */) { + if (container.kind === 191 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } var inFunction = isInsideFunction(node.parent, container); var current = container; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } @@ -18411,7 +18762,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { + if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18422,35 +18773,35 @@ var ts; function checkThisExpression(node) { // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, true); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 171 /* ArrowFunction */) { - container = ts.getThisContainer(container, false); + if (container.kind === 172 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* 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 214 /* EnumDeclaration */: + case 215 /* 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 141 /* Constructor */: + case 142 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18465,98 +18816,105 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135 /* Parameter */) { + if (n.kind === 136 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 172 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134 /* ComputedPropertyName */) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 141 /* Constructor */; + return container.kind === 142 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) // 'super' property access is allowed // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor - // super property access might appear in arrow functions with arbitrary deep nesting - needToCaptureLexicalThis = false; - while (container && container.kind === 171 /* 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 && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */; } else { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */ || - container.kind === 138 /* PropertyDeclaration */ || - container.kind === 137 /* PropertySignature */ || - container.kind === 141 /* Constructor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */ || + container.kind === 139 /* PropertyDeclaration */ || + container.kind === 138 /* PropertySignature */ || + container.kind === 142 /* Constructor */; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 512 /* SuperStatic */; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256 /* SuperInstance */; - returnType = baseClassType; - } - if (container.kind === 141 /* 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; - } - if (!isCallExpression && needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133 /* ComputedPropertyName */) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter) { @@ -18592,7 +18950,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18625,7 +18983,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18636,8 +18994,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 141 /* Constructor */ || - functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { + functionDecl.kind === 142 /* Constructor */ || + functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -18659,7 +19017,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167 /* TaggedTemplateExpression */) { + if (template.parent.kind === 168 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -18667,13 +19025,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -18769,7 +19127,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, undefined) : undefined); + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -18780,7 +19138,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 235 /* JsxAttribute */) { + if (expr.parent.kind === 236 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -18790,7 +19148,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236 /* JsxSpreadAttribute */) { + if (expr.kind === 237 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -18811,38 +19169,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 161 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 171 /* ArrowFunction */: - case 201 /* ReturnStatement */: + case 172 /* ArrowFunction */: + case 202 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 187 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); + case 188 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return getContextualType(parent); - case 237 /* JsxExpression */: - case 236 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 237 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -18859,7 +19217,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; + return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18873,7 +19231,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 !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18887,19 +19245,13 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - // The signature set of all constituent type with call signatures should match - // So number of signatures allowed is either 0 or 1 - if (signatureList && - getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { // Signatures aren't identical, do not use return undefined; } @@ -18919,23 +19271,36 @@ var ts; } return result; } - // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is - // used as a special marker for other purposes. + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 242 /* PropertyAssignment */) { + if (parent.kind === 243 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161 /* ArrayLiteralExpression */) { + if (parent.kind === 162 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18948,7 +19313,7 @@ var ts; // So the fact that contextualMapper is passed is not important, because the operand of a spread // element is not contextually typed. var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -18960,7 +19325,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18975,7 +19340,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -18984,7 +19349,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -18995,7 +19360,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 /* 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, @@ -19035,11 +19400,11 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); } } return links.resolvedType; @@ -19054,18 +19419,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 === 242 /* PropertyAssignment */ || - memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 243 /* PropertyAssignment */ || + memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242 /* PropertyAssignment */) { + if (memberDecl.kind === 243 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140 /* MethodDeclaration */) { + else if (memberDecl.kind === 141 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19085,7 +19450,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 === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19096,7 +19461,7 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); + result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -19129,35 +19494,39 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66 /* Identifier */) { + if (lhs.kind === 67 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); // Check that the closing tag matches if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: checkJsxExpression(child); break; - case 230 /* JsxElement */: + case 231 /* JsxElement */: checkJsxElement(child); break; - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 233 /* JsxText */); + ts.Debug.assert(child.kind === 234 /* JsxText */); } } return jsxElementType || anyType; @@ -19173,7 +19542,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132 /* QualifiedName */) { + if (tagName.kind === 133 /* QualifiedName */) { return false; } else { @@ -19190,10 +19559,19 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -19269,7 +19647,7 @@ var ts; return intrinsicElementsType.symbol; } // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -19279,22 +19657,24 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; + var valueSymbol = resolveJsxTagName(node); // Look up the value in the current scope - if (node.tagName.kind === 66 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -19302,10 +19682,9 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued @@ -19324,15 +19703,10 @@ var ts; if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { @@ -19347,7 +19721,7 @@ var ts; /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); // JSX.ElementAttributesProperty [symbol] var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] @@ -19383,7 +19757,7 @@ var ts; if (links.jsxFlags & 4 /* ClassElement */) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -19465,7 +19839,7 @@ var ts; // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -19477,11 +19851,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235 /* JsxAttribute */) { + if (node.attributes[i].kind === 236 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19511,7 +19885,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 : 138 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19527,8 +19901,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92 /* SuperKeyword */) { - var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + if (left.kind === 93 /* SuperKeyword */) { + var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19538,7 +19912,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 (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -19571,7 +19945,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 92 /* SuperKeyword */) { + if (left.kind === 93 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -19621,7 +19995,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 /* PropertyAccessExpression */ + var left = node.kind === 164 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -19637,7 +20011,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 167 /* 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); @@ -19656,7 +20030,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8 /* StringLiteral */)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -19684,7 +20058,7 @@ var ts; } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -19714,10 +20088,10 @@ var ts; * Otherwise, returns undefined. */ function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 /* StringLiteral */ || indexArgumentExpression.kind === 7 /* NumericLiteral */) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); } @@ -19739,7 +20113,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -19766,10 +20140,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 136 /* Decorator */) { + else if (node.kind !== 137 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -19799,13 +20173,13 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } @@ -19813,7 +20187,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -19835,7 +20209,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182 /* SpreadElementExpression */) { + if (arg && arg.kind === 183 /* SpreadElementExpression */) { return i; } } @@ -19847,13 +20221,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* 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 === 180 /* TemplateExpression */) { + if (tagExpression.template.kind === 181 /* 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; @@ -19866,20 +20240,20 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { isDecorator = true; typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -19922,7 +20296,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -19958,7 +20332,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20017,14 +20391,14 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { - argType = arg.kind === 8 /* StringLiteral */ && !reportErrors + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -20049,16 +20423,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20083,25 +20457,25 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 135 /* Parameter */: + case 136 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20126,25 +20500,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135 /* Parameter */: + case 136 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20173,35 +20547,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 66 /* Identifier */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 67 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -20227,18 +20601,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20271,10 +20645,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20286,8 +20660,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 136 /* Decorator */ || - (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { + if (node.kind === 137 /* Decorator */ || + (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20296,11 +20670,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20309,13 +20683,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 136 /* Decorator */; + var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 137 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 92 /* SuperKeyword */) { + if (node.expression.kind !== 93 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20412,17 +20786,18 @@ var ts; // in arguments too early. If possible, we'd like to only type them once we know the correct // overload. However, this matters for the case where the call is correct. When the call is // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -20441,6 +20816,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -20463,7 +20841,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) : undefined; while (true) { candidate = originalCandidate; @@ -20471,7 +20849,7 @@ var ts; var typeArgumentTypes = void 0; if (typeArguments) { typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); @@ -20483,7 +20861,7 @@ var ts; } candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; @@ -20518,7 +20896,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -20592,7 +20970,7 @@ var ts; // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */); if (valueDecl && valueDecl.flags & 256 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -20651,16 +21029,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135 /* Parameter */: + case 136 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -20697,16 +21075,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165 /* CallExpression */) { + if (node.kind === 166 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166 /* NewExpression */) { + else if (node.kind === 167 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 168 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -20724,15 +21102,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { return voidType; } - if (node.kind === 166 /* NewExpression */) { + if (node.kind === 167 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 /* Constructor */ && - declaration.kind !== 145 /* ConstructSignature */ && - declaration.kind !== 150 /* ConstructorType */) { + declaration.kind !== 142 /* Constructor */ && + declaration.kind !== 146 /* ConstructSignature */ && + declaration.kind !== 151 /* 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); @@ -20746,7 +21124,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -20765,13 +21143,51 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -20791,7 +21207,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189 /* Block */) { + if (func.body.kind !== 190 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -20910,7 +21326,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -20925,7 +21341,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 !== 189 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { return; } var bodyBlock = func.body; @@ -20943,10 +21359,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 !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -20959,37 +21375,44 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21011,7 +21434,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { checkSourceElement(node.body); } else { @@ -21057,24 +21480,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 66 /* Identifier */: { + case 67 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // 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 163 /* PropertyAccessExpression */: { + case 164 /* 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 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21082,22 +21505,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: { + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 164 /* ElementAccessExpression */: { + case 165 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8 /* StringLiteral */) { + if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21141,17 +21564,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return booleanType; - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21217,7 +21640,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -21231,7 +21654,7 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { @@ -21243,7 +21666,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21268,12 +21691,12 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21298,7 +21721,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { + if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21311,14 +21734,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161 /* ArrayLiteralExpression */) { + if (target.kind === 162 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21326,38 +21749,38 @@ var ts; function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36 /* AsteriskToken */: - case 57 /* AsteriskEqualsToken */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 38 /* PercentToken */: - case 59 /* PercentEqualsToken */: - case 35 /* MinusToken */: - case 56 /* MinusEqualsToken */: - case 41 /* LessThanLessThanToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: + case 37 /* AsteriskToken */: + case 58 /* AsteriskEqualsToken */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 39 /* PercentToken */: + case 60 /* PercentEqualsToken */: + case 36 /* MinusToken */: + case 57 /* MinusEqualsToken */: + case 42 /* LessThanLessThanToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -21385,8 +21808,8 @@ var ts; } } return numberType; - case 34 /* PlusToken */: - case 55 /* PlusEqualsToken */: + case 35 /* PlusToken */: + case 56 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -21420,44 +21843,44 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55 /* PlusEqualsToken */) { + if (operator === 56 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88 /* InstanceOfKeyword */: + case 89 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 87 /* InKeyword */: + case 88 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return rightType; - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 54 /* EqualsToken */: + case 55 /* EqualsToken */: checkAssignmentOperator(rightType); - return rightType; - case 23 /* CommaToken */: + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: return rightType; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21467,21 +21890,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - return 50 /* BarBarToken */; - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - return 32 /* ExclamationEqualsEqualsToken */; - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: - return 49 /* AmpersandAmpersandToken */; + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + return 51 /* BarBarToken */; + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + return 33 /* ExclamationEqualsEqualsToken */; + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: + return 50 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -21492,7 +21915,7 @@ var ts; // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); } } } @@ -21530,7 +21953,7 @@ var ts; // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { @@ -21542,10 +21965,10 @@ var ts; if (func.type) { var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); } } } @@ -21588,7 +22011,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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -21599,14 +22022,14 @@ 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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -21629,7 +22052,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -21641,9 +22064,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 67 /* Identifier */ || node.kind === 133 /* 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); } @@ -21657,78 +22080,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkIdentifier(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return checkThisExpression(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return checkSuperExpression(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return nullType; - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return booleanType; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return checkTemplateExpression(node); - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return stringType; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return checkCallExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return checkClassExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return checkAssertion(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkDeleteExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return checkVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return checkAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return undefinedType; - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return checkYieldExpression(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return checkJsxExpression(node); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return checkJsxElement(node); - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 232 /* JsxOpeningElement */: + case 233 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -21757,7 +22180,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -21774,15 +22197,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 /* MethodDeclaration */ || - node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */; + return node.kind === 141 /* MethodDeclaration */ || + node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 /* Identifier */ && + if (param.name.kind === 67 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -21792,31 +22215,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 171 /* ArrowFunction */: - case 144 /* CallSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 149 /* FunctionType */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 172 /* ArrowFunction */: + case 145 /* CallSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 150 /* FunctionType */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || - node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || - node.kind === 145 /* ConstructSignature */) { + else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || + node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || + node.kind === 146 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147 /* TypePredicate */) { + if (node.type.kind === 148 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -21825,7 +22248,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -21835,19 +22258,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 /* ObjectBindingPattern */ || - param.name.kind === 159 /* ArrayBindingPattern */) { + if (param.name.kind === 159 /* ObjectBindingPattern */ || + param.name.kind === 160 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 /* Identifier */ && + if (element.name.kind === 67 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 /* ArrayBindingPattern */ || - element.name.kind === 158 /* ObjectBindingPattern */) { + else if (element.name.kind === 160 /* ArrayBindingPattern */ || + element.name.kind === 159 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -21871,10 +22294,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -21902,7 +22325,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212 /* InterfaceDeclaration */) { + if (node.kind === 213 /* 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 @@ -21922,7 +22345,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -21930,7 +22353,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22402,80 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; + return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 162 /* ObjectLiteralExpression */: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94 /* ThisKeyword */) { + if (n.kind === 95 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { + else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 /* PropertyDeclaration */ && + return n.kind === 139 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { - // The first statement in the body of a constructor must be a super call if both of the following are true: + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { 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 { // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -22037,7 +22484,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142 /* GetAccessor */) { + if (node.kind === 143 /* 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); } @@ -22045,7 +22492,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 === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; + var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22141,9 +22588,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 === 212 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22161,7 +22608,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22247,7 +22694,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 === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); + ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* 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); @@ -22283,7 +22730,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22294,7 +22741,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 === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { + if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22378,8 +22825,6 @@ var ts; if (!produceDiagnostics) { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. // if localSymbol is defined on node then node itself is exported - check is required var symbol = node.localSymbol; if (!symbol) { @@ -22397,38 +22842,55 @@ var ts; } // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1 /* Export */)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 215 /* ModuleDeclaration */: - return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 216 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22505,7 +22967,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); @@ -22672,22 +23134,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135 /* Parameter */: + case 136 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -22700,9 +23162,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 148 /* TypeReference */) { + if (node && node.kind === 149 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); + var rootSymbol = resolveName(root, root.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { markAliasSymbolAsReferenced(rootSymbol); } @@ -22714,19 +23176,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 135 /* Parameter */: + case 136 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -22755,25 +23217,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 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 143 /* SetAccessor */: - case 142 /* GetAccessor */: - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 144 /* SetAccessor */: + case 143 /* GetAccessor */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135 /* Parameter */) { + if (node.kind === 136 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -22799,7 +23261,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 === 133 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -22848,11 +23310,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -22871,12 +23333,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 /* PropertyDeclaration */ || - node.kind === 137 /* PropertySignature */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */) { + if (node.kind === 139 /* PropertyDeclaration */ || + node.kind === 138 /* PropertySignature */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -22885,7 +23347,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -22901,7 +23363,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 66 /* Identifier */; + var isDeclaration_1 = node.kind !== 67 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -22924,7 +23386,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66 /* Identifier */; + var isDeclaration_2 = node.kind !== 67 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -22938,12 +23400,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 216 /* 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 === 245 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 246 /* 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_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -22978,27 +23440,27 @@ 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 === 208 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 191 /* 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 === 189 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 216 /* ModuleBlock */ || - container.kind === 215 /* ModuleDeclaration */ || - container.kind === 245 /* SourceFile */); + (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 217 /* ModuleBlock */ || + container.kind === 216 /* ModuleDeclaration */ || + container.kind === 246 /* 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 @@ -23013,18 +23475,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66 /* Identifier */) { + if (n.kind === 67 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // 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 === 135 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23050,7 +23512,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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23061,14 +23523,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -23078,7 +23540,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -23090,13 +23552,13 @@ var ts; error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { + if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23119,7 +23581,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23157,12 +23619,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23182,14 +23644,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 === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* 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 === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* 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. @@ -23197,14 +23659,14 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } } } @@ -23218,7 +23680,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 === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* 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); @@ -23232,7 +23694,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 === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -23261,7 +23723,7 @@ var ts; } function checkRightHandSideOfForOf(rhsExpression) { var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); } function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { if (isTypeAny(inputType)) { @@ -23404,8 +23866,8 @@ var ts; if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { return type.typeArguments[0]; } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); } /** * This function does the following steps: @@ -23428,7 +23890,7 @@ var ts; ts.Debug.assert(languageVersion < 2 /* ES6 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, true, true); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); var hasStringConstituent = arrayOrStringType !== arrayType; var reportedError = false; if (hasStringConstituent) { @@ -23471,7 +23933,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); + return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -23494,10 +23956,10 @@ var ts; // for generators. return; } - if (func.kind === 143 /* SetAccessor */) { + if (func.kind === 144 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141 /* Constructor */) { + else if (func.kind === 142 /* 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); } @@ -23533,7 +23995,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 === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -23545,14 +24007,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 239 /* 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. var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -23566,7 +24028,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 205 /* 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; @@ -23596,7 +24058,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -23671,7 +24133,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 === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -23842,7 +24304,7 @@ var ts; // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. @@ -23890,7 +24352,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; + return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -23960,7 +24422,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* 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); @@ -23981,7 +24443,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24014,32 +24476,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -24050,22 +24492,48 @@ var ts; }); nodeLinks.flags |= 8192 /* EnumValuesComputed */; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176 /* PrefixUnaryExpression */: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177 /* PrefixUnaryExpression */: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34 /* PlusToken */: return value; - case 35 /* MinusToken */: return -value; - case 48 /* TildeToken */: return ~value; + case 35 /* PlusToken */: return value_1; + case 36 /* MinusToken */: return -value_1; + case 49 /* TildeToken */: return ~value_1; } return undefined; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24075,41 +24543,41 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45 /* BarToken */: return left | right; - case 44 /* AmpersandToken */: return left & right; - case 42 /* GreaterThanGreaterThanToken */: return left >> right; - case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 41 /* LessThanLessThanToken */: return left << right; - case 46 /* CaretToken */: return left ^ right; - case 36 /* AsteriskToken */: return left * right; - case 37 /* SlashToken */: return left / right; - case 34 /* PlusToken */: return left + right; - case 35 /* MinusToken */: return left - right; - case 38 /* PercentToken */: return left % right; + case 46 /* BarToken */: return left | right; + case 45 /* AmpersandToken */: return left & right; + case 43 /* GreaterThanGreaterThanToken */: return left >> right; + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 42 /* LessThanLessThanToken */: return left << right; + case 47 /* CaretToken */: return left ^ right; + case 37 /* AsteriskToken */: return left * right; + case 38 /* SlashToken */: return left / right; + case 35 /* PlusToken */: return left + right; + case 36 /* MinusToken */: return left - right; + case 39 /* PercentToken */: return left % right; } return undefined; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return +e.text; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 66 /* Identifier */: - case 164 /* ElementAccessExpression */: - case 163 /* PropertyAccessExpression */: + case 67 /* Identifier */: + case 165 /* ElementAccessExpression */: + case 164 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66 /* Identifier */) { + if (e.kind === 67 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type - enumType = currentType; + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164 /* ElementAccessExpression */) { + if (e.kind === 165 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8 /* StringLiteral */) { + e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; } expression = e.expression; @@ -24122,26 +24590,26 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 66 /* Identifier */) { + if (current.kind === 67 /* Identifier */) { break; } - else if (current.kind === 163 /* PropertyAccessExpression */) { + else if (current.kind === 164 /* PropertyAccessExpression */) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); + enumType_1 = checkExpression(expression); // allow references to constant members of other enums - if (!(enumType.symbol && (enumType.symbol.flags & 384 /* Enum */))) { + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8 /* EnumMember */)) { return undefined; } @@ -24152,6 +24620,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24664,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 !== 214 /* EnumDeclaration */) { + if (declaration.kind !== 215 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24217,8 +24687,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 /* ClassDeclaration */ || - (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 /* ClassDeclaration */ || + (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24241,7 +24711,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -24250,7 +24720,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -24274,7 +24744,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24294,28 +24764,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { node = node.left; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8 /* StringLiteral */) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -24338,7 +24808,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 === 227 /* ExportSpecifier */ ? + var message = node.kind === 228 /* 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)); @@ -24365,7 +24835,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24402,7 +24872,7 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.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); } @@ -24422,8 +24892,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24437,7 +24907,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { + if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -24452,8 +24922,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { + var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -24461,7 +24931,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { markExportAsReferenced(node); } else { @@ -24480,10 +24950,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245 /* SourceFile */) { + if (node.kind === 246 /* SourceFile */) { return node.statements; } - if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -24522,118 +24992,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return checkTypeParameter(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return checkParameter(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return checkPropertyDeclaration(node); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return checkSignatureDeclaration(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return checkMethodDeclaration(node); - case 141 /* Constructor */: + case 142 /* Constructor */: return checkConstructorDeclaration(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return checkAccessorDeclaration(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return checkTypeReferenceNode(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return checkTypePredicate(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return checkTypeQuery(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return checkTypeLiteral(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return checkArrayType(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return checkTupleType(node); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return checkSourceElement(node.type); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return checkBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return checkVariableStatement(node); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return checkExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return checkIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return checkDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return checkWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return checkForStatement(node); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return checkForInStatement(node); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return checkForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return checkReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return checkSwitchStatement(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return checkLabeledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return checkThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return checkTryStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return checkBindingElement(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return checkClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return checkImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return checkExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return checkExportAssignment(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -24648,95 +25118,95 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202 /* WithStatement */: + case 203 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136 /* Decorator */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 160 /* BindingElement */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 180 /* TemplateExpression */: - case 187 /* TemplateSpan */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 175 /* AwaitExpression */: - case 172 /* DeleteExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 181 /* YieldExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 217 /* CaseBlock */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 208 /* VariableDeclaration */: - case 209 /* VariableDeclarationList */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 224 /* ExportAssignment */: - case 245 /* SourceFile */: - case 237 /* JsxExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: + case 137 /* Decorator */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 161 /* BindingElement */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 181 /* TemplateExpression */: + case 188 /* TemplateSpan */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 176 /* AwaitExpression */: + case 173 /* DeleteExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 182 /* YieldExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 218 /* CaseBlock */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 209 /* VariableDeclaration */: + case 210 /* VariableDeclarationList */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 225 /* ExportAssignment */: + case 246 /* SourceFile */: + case 238 /* JsxExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -24822,7 +25292,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -24845,25 +25315,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -24872,13 +25342,16 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -24912,43 +25385,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 /* Identifier */ && + return name.kind === 67 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134 /* TypeParameter */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 135 /* TypeParameter */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* 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 === 132 /* QualifiedName */) { + while (node.parent && node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 148 /* TypeReference */; + return node.parent && node.parent.kind === 149 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -24960,11 +25433,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224 /* ExportAssignment */) { + if (entityName.parent.kind === 225 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 163 /* PropertyAccessExpression */) { + if (entityName.kind !== 164 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -24974,11 +25447,13 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || + (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 235 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -24986,20 +25461,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163 /* PropertyAccessExpression */) { + else if (entityName.kind === 164 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132 /* QualifiedName */) { + else if (entityName.kind === 133 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25008,22 +25483,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235 /* JsxAttribute */) { + else if (entityName.parent.kind === 236 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147 /* TypePredicate */) { - return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + if (entityName.parent.kind === 148 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -25032,39 +25507,50 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 /* BindingElement */ && + node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 118 /* ConstructorKeyword */: + case 119 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && + ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25081,7 +25567,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 === 243 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25103,28 +25589,28 @@ var ts; return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; } if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -25195,11 +25681,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25214,11 +25700,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return true; } return false; @@ -25229,7 +25715,7 @@ var ts; if (links.isNestedRedeclaration === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -25248,22 +25734,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224 /* ExportAssignment */: - return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225 /* ExportAssignment */: + return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25276,7 +25762,11 @@ var ts; return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -25321,7 +25811,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244 /* EnumMember */) { + if (node.kind === 245 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25336,14 +25826,16 @@ var ts; function isFunctionType(type) { return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(node) { + function getTypeReferenceSerializationKind(typeName) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25857,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -25400,7 +25892,7 @@ var ts; function getReferencedValueSymbol(reference) { return getNodeLinks(reference).resolvedSymbol || resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, undefined); + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); @@ -25409,13 +25901,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* 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); + resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -25457,7 +25949,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +25970,7 @@ var ts; getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types - globalArrayType = getGlobalType("Array", 1); + globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -25489,10 +25982,10 @@ var ts; getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); @@ -25503,9 +25996,9 @@ var ts; globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; @@ -25549,7 +26042,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 === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { + else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* 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); @@ -25559,38 +26052,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 215 /* ModuleDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 135 /* Parameter */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 216 /* ModuleDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 136 /* Parameter */: break; - case 210 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 211 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 190 /* VariableStatement */: - case 213 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 191 /* VariableStatement */: + case 214 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 214 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 215 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -25605,14 +26098,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 108 /* ProtectedKeyword */: - case 107 /* PrivateKeyword */: + case 110 /* PublicKeyword */: + case 109 /* ProtectedKeyword */: + case 108 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 109 /* PublicKeyword */) { + if (modifier.kind === 110 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 108 /* ProtectedKeyword */) { + else if (modifier.kind === 109 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -25629,11 +26122,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 107 /* PrivateKeyword */) { + if (modifier.kind === 108 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -25642,17 +26135,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -25661,7 +26154,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -25674,42 +26167,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211 /* ClassDeclaration */) { - if (node.kind !== 140 /* MethodDeclaration */) { + if (node.kind !== 212 /* ClassDeclaration */) { + if (node.kind !== 141 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -25721,14 +26214,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -25736,7 +26229,7 @@ var ts; break; } } - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -25754,10 +26247,10 @@ var ts; } return; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -25769,10 +26262,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140 /* MethodDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -25820,16 +26313,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -25840,7 +26331,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171 /* ArrowFunction */) { + if (node.kind === 172 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -25875,7 +26366,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 !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { + if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -25908,7 +26399,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184 /* OmittedExpression */) { + if (arg.kind === 185 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -25935,7 +26426,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -25948,7 +26439,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -25964,14 +26455,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -25982,19 +26473,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 133 /* ComputedPropertyName */) { + if (node.kind !== 134 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26020,8 +26511,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 /* OmittedExpression */ || - name_16.kind === 133 /* ComputedPropertyName */) { + if (prop.kind === 185 /* OmittedExpression */ || + name_16.kind === 134 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; @@ -26035,21 +26526,21 @@ 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 === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { + if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7 /* NumericLiteral */) { + if (name_16.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140 /* MethodDeclaration */) { + else if (prop.kind === 141 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 142 /* GetAccessor */) { + else if (prop.kind === 143 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 143 /* SetAccessor */) { + else if (prop.kind === 144 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26081,7 +26572,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236 /* JsxSpreadAttribute */) { + if (attr.kind === 237 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26093,7 +26584,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26102,24 +26593,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* 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 === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* 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 === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* 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); @@ -26142,10 +26633,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143 /* SetAccessor */) { + else if (kind === 144 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26170,7 +26661,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26180,7 +26671,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.parent.kind === 163 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26204,22 +26695,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 === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* 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 === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* 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 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return true; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26231,26 +26722,26 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204 /* LabeledStatement */: + case 205 /* 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 === 199 /* ContinueStatement */ - && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 203 /* SwitchStatement */: - if (node.kind === 200 /* BreakStatement */ && !node.label) { + case 204 /* SwitchStatement */: + if (node.kind === 201 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } break; default: - if (isIterationStatement(current, false) && !node.label) { + if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { // unlabeled break or continue within iteration statement - ok return false; } @@ -26259,13 +26750,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* 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 === 200 /* BreakStatement */ + var message = node.kind === 201 /* 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); @@ -26277,7 +26768,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { + if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26287,7 +26778,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { + if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26314,7 +26805,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26323,7 +26814,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26340,15 +26831,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return false; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26364,13 +26855,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176 /* PrefixUnaryExpression */) { + if (expression.kind === 177 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 7 /* NumericLiteral */) { + if (expression.kind === 8 /* NumericLiteral */) { // Allows for scientific notation since literalExpression.text was formed by // coercing a number to a string. Sometimes this coercion can yield a string // in scientific notation. @@ -26393,7 +26884,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 === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -26436,7 +26927,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -26456,12 +26947,12 @@ var ts; return true; } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* 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 === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* 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; } @@ -26481,11 +26972,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 212 /* InterfaceDeclaration */ || - node.kind === 219 /* ImportDeclaration */ || - node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ExportDeclaration */ || - node.kind === 224 /* ExportAssignment */ || + if (node.kind === 213 /* InterfaceDeclaration */ || + node.kind === 220 /* ImportDeclaration */ || + node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ExportDeclaration */ || + node.kind === 225 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -26495,7 +26986,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 === 190 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -26521,7 +27012,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 === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -26542,7 +27033,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } } @@ -26603,7 +27094,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -26679,10 +27170,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208 /* VariableDeclaration */) { + if (declaration.kind === 209 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { + else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -26700,7 +27191,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 === 219 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 220 /* 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; @@ -26710,12 +27201,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -26798,7 +27289,7 @@ var ts; var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -26807,49 +27298,49 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 8 /* StringLiteral */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return emitTypeReference(type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return emitTypeQuery(type); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return emitArrayType(type); - case 154 /* TupleType */: + case 155 /* TupleType */: return emitTupleType(type); - case 155 /* UnionType */: + case 156 /* UnionType */: return emitUnionType(type); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return emitIntersectionType(type); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return emitParenType(type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return emitTypeLiteral(type); - case 66 /* Identifier */: + case 67 /* Identifier */: return emitEntityName(type); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitEntityName(type); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -26858,13 +27349,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -26945,7 +27436,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -26965,7 +27456,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -26984,10 +27475,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 /* ImportEqualsDeclaration */ || - (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 /* ImportEqualsDeclaration */ || + (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -26997,7 +27488,7 @@ var ts; }); } else { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27015,23 +27506,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return writeVariableStatement(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return writeClassDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27047,7 +27538,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 212 /* InterfaceDeclaration */) { + else if (node.kind !== 213 /* InterfaceDeclaration */) { write("declare "); } } @@ -27096,7 +27587,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221 /* NamespaceImport */) { + if (namedBindings.kind === 222 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27124,7 +27615,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27182,7 +27673,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216 /* ModuleBlock */) { + while (node.body.kind !== 217 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27199,14 +27690,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -27243,7 +27738,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27254,15 +27749,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 === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || - node.parent.kind === 139 /* MethodSignature */ || - node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.kind === 144 /* CallSignature */ || - node.parent.kind === 145 /* ConstructSignature */); + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || + node.parent.kind === 140 /* MethodSignature */ || + node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.kind === 145 /* CallSignature */ || + node.parent.kind === 146 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27273,31 +27768,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 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* 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 === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* 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 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27328,7 +27823,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + if (node.parent.parent.kind === 212 /* 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 : @@ -27368,9 +27863,9 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -27389,7 +27884,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); write(" {"); writeLine(); increaseIndent(); @@ -27412,7 +27907,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 !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -27422,10 +27917,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -27434,14 +27929,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* 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 === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { + else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -27450,7 +27945,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 === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* 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 : @@ -27482,7 +27977,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { elements.push(element); } } @@ -27503,7 +27998,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28047,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 === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -27565,7 +28060,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 /* GetAccessor */ + return accessor.kind === 143 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -27574,7 +28069,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 144 /* 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 ? @@ -27624,17 +28119,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140 /* MethodDeclaration */) { + else if (node.kind === 141 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141 /* Constructor */) { + else if (node.kind === 142 /* Constructor */) { write("constructor"); } else { @@ -27652,11 +28147,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { + if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("["); } else { @@ -27666,22 +28161,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -27692,26 +28187,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* 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 144 /* CallSignature */: + case 145 /* 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 146 /* IndexSignature */: + case 147 /* 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 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27719,7 +28214,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 === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* 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 : @@ -27733,7 +28228,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210 /* FunctionDeclaration */: + case 211 /* 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 : @@ -27764,13 +28259,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.parent.kind === 152 /* TypeLiteral */) { + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -27786,24 +28281,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141 /* Constructor */: + case 142 /* 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 145 /* ConstructSignature */: + case 146 /* 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 144 /* CallSignature */: + case 145 /* 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 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27811,7 +28306,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 === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* 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 : @@ -27824,7 +28319,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 210 /* FunctionDeclaration */: + case 211 /* 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 : @@ -27836,12 +28331,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 === 158 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -27860,7 +28355,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184 /* OmittedExpression */) { + if (bindingElement.kind === 185 /* 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) @@ -27869,7 +28364,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 160 /* BindingElement */) { + else if (bindingElement.kind === 161 /* 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" @@ -27879,10 +28374,8 @@ var ts; // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. // In the case of rest element, we will omit rest element. @@ -27894,7 +28387,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -27910,40 +28403,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 212 /* InterfaceDeclaration */: - case 211 /* ClassDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 211 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 213 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, !node.importClause); - case 225 /* ExportDeclaration */: + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return writeFunctionDeclaration(node); - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessorDeclaration(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return emitPropertyDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFile(node); } } @@ -27952,7 +28445,7 @@ var ts; ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); referencePathsOutput += "/// " + newLine; @@ -28026,18 +28519,18 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || 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, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } // Sort and make the unique list of diagnostics @@ -28100,7 +28593,7 @@ var ts; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; /** Emit a node */ - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ var emitStart = function (node) { }; /** Called once the emit of the node is done */ @@ -28135,7 +28628,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28688,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 /* StringLiteral */ ? + var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -28207,19 +28700,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return makeUniqueName(node.text); - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 219 /* ImportDeclaration */: - case 225 /* ExportDeclaration */: + case 220 /* ImportDeclaration */: + case 226 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: - case 224 /* ExportAssignment */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 225 /* ExportAssignment */: return generateNameForExportDefault(); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28285,7 +28778,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -28391,7 +28884,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_21 = node.name; - if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -28409,20 +28902,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */ || - node.kind === 215 /* ModuleDeclaration */ || - node.kind === 211 /* ClassDeclaration */ || - node.kind === 214 /* EnumDeclaration */) { + else if (node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */ || + node.kind === 216 /* ModuleDeclaration */ || + node.kind === 212 /* ClassDeclaration */ || + node.kind === 215 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 133 /* ComputedPropertyName */ + scopeName = name_22.kind === 134 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -28481,7 +28974,7 @@ var ts; } else { // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; } // Write sourcemap url to the js file and write the js file @@ -28517,7 +29010,9 @@ var ts; 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, + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); } else { @@ -28532,7 +29027,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245 /* SourceFile */) { + if (node.kind !== 246 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -28543,8 +29038,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29055,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66 /* Identifier */); + var result = ts.createSynthesizedNode(67 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -28667,7 +29165,14 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -28680,11 +29185,11 @@ var ts; } function emitCommaList(nodes) { if (nodes) { - emitList(nodes, 0, nodes.length, false, false); + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); } } function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); + emitLinesStartingAt(nodes, /*startIndex*/ 0); } function emitLinesStartingAt(nodes, startIndex) { for (var i = startIndex; i < nodes.length; i++) { @@ -28693,7 +29198,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: @@ -28706,7 +29211,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -28720,7 +29225,7 @@ var ts; // 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, '"'); + 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. @@ -28730,17 +29235,17 @@ var ts; // 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 */: + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -28757,18 +29262,18 @@ var ts; // 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 */; + var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* 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 + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { literalEmitter(node.template); } else { @@ -28795,11 +29300,11 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 180 /* TemplateExpression */) { + if (node.template.kind === 181 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; + var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -28833,7 +29338,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 170 /* 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 @@ -28875,11 +29380,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent.expression === template; - case 167 /* TaggedTemplateExpression */: - case 169 /* ParenthesizedExpression */: + case 168 /* TaggedTemplateExpression */: + case 170 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -28900,20 +29405,20 @@ 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 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 1 /* GreaterThan */; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -28928,10 +29433,10 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28942,9 +29447,9 @@ var ts; /// about keywords, just non-identifier characters function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28976,37 +29481,37 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_2 === 0) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -29029,16 +29534,16 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 233 /* JsxText */) { + if (children[i].kind === 234 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -29051,11 +29556,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -29075,11 +29580,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29087,11 +29592,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231 /* JsxSelfClosingElement */) { + if (node.kind === 232 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29110,11 +29615,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29122,11 +29627,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 !== 160 /* BindingElement */); - if (node.kind === 8 /* StringLiteral */) { + ts.Debug.assert(node.kind !== 161 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 133 /* ComputedPropertyName */) { + else if (node.kind === 134 /* 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: @@ -29158,7 +29663,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29675,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161 /* ArrayLiteralExpression */: - case 178 /* BinaryExpression */: - case 165 /* CallExpression */: - case 238 /* CaseClause */: - case 133 /* ComputedPropertyName */: - case 179 /* ConditionalExpression */: - case 136 /* Decorator */: - case 172 /* DeleteExpression */: - case 194 /* DoStatement */: - case 164 /* ElementAccessExpression */: - case 224 /* ExportAssignment */: - case 192 /* ExpressionStatement */: - case 185 /* ExpressionWithTypeArguments */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 193 /* IfStatement */: - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: - case 166 /* NewExpression */: - case 169 /* ParenthesizedExpression */: - case 177 /* PostfixUnaryExpression */: - case 176 /* PrefixUnaryExpression */: - case 201 /* ReturnStatement */: - case 243 /* ShorthandPropertyAssignment */: - case 182 /* SpreadElementExpression */: - case 203 /* SwitchStatement */: - case 167 /* TaggedTemplateExpression */: - case 187 /* TemplateSpan */: - case 205 /* ThrowStatement */: - case 168 /* TypeAssertionExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 181 /* YieldExpression */: + case 162 /* ArrayLiteralExpression */: + case 179 /* BinaryExpression */: + case 166 /* CallExpression */: + case 239 /* CaseClause */: + case 134 /* ComputedPropertyName */: + case 180 /* ConditionalExpression */: + case 137 /* Decorator */: + case 173 /* DeleteExpression */: + case 195 /* DoStatement */: + case 165 /* ElementAccessExpression */: + case 225 /* ExportAssignment */: + case 193 /* ExpressionStatement */: + case 186 /* ExpressionWithTypeArguments */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 194 /* IfStatement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: + case 237 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 167 /* NewExpression */: + case 170 /* ParenthesizedExpression */: + case 178 /* PostfixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: + case 202 /* ReturnStatement */: + case 244 /* ShorthandPropertyAssignment */: + case 183 /* SpreadElementExpression */: + case 204 /* SwitchStatement */: + case 168 /* TaggedTemplateExpression */: + case 188 /* TemplateSpan */: + case 206 /* ThrowStatement */: + case 169 /* TypeAssertionExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 182 /* YieldExpression */: return true; - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 209 /* VariableDeclaration */: return parent.initializer === node; - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return parent.expression === node; - case 171 /* ArrowFunction */: - case 170 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 171 /* FunctionExpression */: return parent.body === node; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return parent.left === node; } return false; @@ -29233,7 +29740,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245 /* SourceFile */) { + if (container.kind === 246 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -29248,13 +29755,13 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220 /* ImportClause */) { + if (declaration.kind === 221 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223 /* ImportSpecifier */) { + else if (declaration.kind === 224 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); @@ -29272,13 +29779,13 @@ var ts; } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 208 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 209 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -29322,13 +29829,13 @@ var ts; function emitObjectBindingPattern(node) { write("{ "); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write(" }"); } function emitArrayBindingPattern(node) { write("["); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write("]"); } function emitBindingElement(node) { @@ -29352,7 +29859,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29366,7 +29873,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +29881,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66 /* Identifier */: - case 161 /* ArrayLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: + case 67 /* Identifier */: + case 162 /* ArrayLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 170 /* 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; @@ -29409,17 +29916,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182 /* SpreadElementExpression */) { + if (e.kind === 183 /* SpreadElementExpression */) { e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { i++; } write("["); @@ -29442,7 +29949,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182 /* SpreadElementExpression */; + return node.kind === 183 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -29451,12 +29958,12 @@ var ts; } else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, true); + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } function emitObjectLiteralBody(node, numElements) { @@ -29471,7 +29978,7 @@ var ts; // 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); + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; @@ -29481,7 +29988,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30019,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { + if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -29564,13 +30071,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242 /* PropertyAssignment */) { + if (property.kind === 243 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 243 /* ShorthandPropertyAssignment */) { + else if (property.kind === 244 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140 /* MethodDeclaration */) { + else if (property.kind === 141 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -29604,7 +30111,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 === 133 /* ComputedPropertyName */) { + if (properties[i].name.kind === 134 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -29620,21 +30127,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -29642,7 +30149,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { + while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -29654,11 +30161,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 /* NewExpression */ && - expr.kind !== 7 /* NumericLiteral */) { + expr.kind !== 167 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -29680,12 +30187,20 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245 /* SourceFile */; + return container && container.kind !== 246 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -29707,21 +30222,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - // do not inline enum values in separate compilation mode - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } // Returns 'true' if the code was actually indented, false otherwise. // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. @@ -29748,10 +30267,20 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -29769,7 +30298,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66 /* Identifier */) { + if (node.left.kind === 67 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -29777,19 +30306,19 @@ var ts; write("("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(node.left, true); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); write(") && "); emitNodeWithoutSourceMap(temp); } else { - emitEntityNameAsExpression(node.left, false); + emitEntityNameAsExpression(node.left, /*useFallback*/ false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -29797,7 +30326,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30341,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { + while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { + if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { emit(node); return node; } @@ -29836,20 +30365,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164 /* ElementAccessExpression */) { + else if (expr.kind === 165 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92 /* SuperKeyword */) { + else if (expr.kind === 93 /* SuperKeyword */) { target = expr; write("_super"); } @@ -29858,7 +30387,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92 /* SuperKeyword */) { + if (target.kind === 93 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -29872,7 +30401,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false, false, true); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } function emitCallExpression(node) { @@ -29881,13 +30410,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; + superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -29929,7 +30458,7 @@ var ts; write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } @@ -29956,12 +30485,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { - if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { + if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { + while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -29972,14 +30501,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 !== 176 /* PrefixUnaryExpression */ && - operand.kind !== 174 /* VoidExpression */ && - operand.kind !== 173 /* TypeOfExpression */ && - operand.kind !== 172 /* DeleteExpression */ && - operand.kind !== 177 /* PostfixUnaryExpression */ && - operand.kind !== 166 /* NewExpression */ && - !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && - !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { + if (operand.kind !== 177 /* PrefixUnaryExpression */ && + operand.kind !== 175 /* VoidExpression */ && + operand.kind !== 174 /* TypeOfExpression */ && + operand.kind !== 173 /* DeleteExpression */ && + operand.kind !== 178 /* PostfixUnaryExpression */ && + operand.kind !== 167 /* NewExpression */ && + !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && + !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) { emit(operand); return; } @@ -29990,29 +30519,29 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75 /* DeleteKeyword */)); + write(ts.tokenToString(76 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100 /* VoidKeyword */)); + write(ts.tokenToString(101 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98 /* TypeOfKeyword */)); + write(ts.tokenToString(99 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); } function emitPrefixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); @@ -30038,12 +30567,12 @@ 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 === 176 /* PrefixUnaryExpression */) { + if (node.operand.kind === 177 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { write(" "); } } @@ -30063,7 +30592,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39 /* PlusPlusToken */) { + if (node.operator === 40 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30076,7 +30605,7 @@ var ts; } } function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); } /* * Checks if given node is a source file level declaration (not nested in module/function). @@ -30094,10 +30623,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245 /* SourceFile */) { + if (current.kind === 246 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { return false; } else { @@ -30106,13 +30635,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && - (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && + (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && - node.operatorToken.kind <= 65 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && + node.operatorToken.kind <= 66 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30121,7 +30650,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -30160,36 +30689,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189 /* Block */) { + if (node && node.kind === 190 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); write(" "); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); return; } - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); + if (node.kind === 217 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216 /* ModuleBlock */) { - emitTempDeclarations(true); + if (node.kind === 217 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { write(" "); emit(node); } @@ -30201,20 +30730,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85 /* IfKeyword */, node.pos); + var endPos = emitToken(86 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 193 /* IfStatement */) { + emitToken(78 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 194 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30226,7 +30755,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { write(" "); } else { @@ -30248,17 +30777,17 @@ var ts; * in system modules where such variable declarations are hoisted. */ function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; } - var tokenKind = 99 /* VarKeyword */; + var tokenKind = 100 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 105 /* LetKeyword */; + tokenKind = 106 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 71 /* ConstKeyword */; + tokenKind = 72 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30267,13 +30796,13 @@ var ts; } else { switch (tokenKind) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: write("var "); break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: write("let "); break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: write("const "); break; } @@ -30298,10 +30827,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30322,13 +30851,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30338,14 +30867,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197 /* ForInStatement */) { + if (node.kind === 198 /* ForInStatement */) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -30369,9 +30898,9 @@ var ts; // 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(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* 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. @@ -30380,7 +30909,7 @@ var ts; // 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 === 66 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 67 /* 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 @@ -30405,7 +30934,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +30943,7 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); writeLine(); @@ -30423,7 +30952,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -30431,12 +30960,12 @@ var ts; 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); + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); } else { // The following call does not include the initializer, so we have // to emit it separately. - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -30452,19 +30981,19 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* 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); + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { emitLines(node.statement.statements); } else { @@ -30476,12 +31005,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91 /* ReturnKeyword */, node.pos); + emitToken(92 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -30492,21 +31021,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93 /* SwitchKeyword */, node.pos); + var endPos = emitToken(94 /* SwitchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(17 /* CloseParenToken */, node.expression.end); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14 /* OpenBraceToken */, startPos); + emitToken(15 /* OpenBraceToken */, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.clauses.end); + emitToken(16 /* CloseBraceToken */, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -30521,7 +31050,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238 /* CaseClause */) { + if (node.kind === 239 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -30556,16 +31085,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69 /* CatchKeyword */, node.pos); + var endPos = emitToken(70 /* CatchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); - emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73 /* DebuggerKeyword */, node.pos); + emitToken(74 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -30576,7 +31105,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215 /* ModuleDeclaration */); + } while (node && node.kind !== 216 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -30595,16 +31124,35 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(174 /* VoidExpression */); + var result = ts.createSynthesizedNode(175 /* VoidExpression */); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + // only allow export default at a source file level + if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1 /* Export */) { writeLine(); @@ -30618,7 +31166,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31174,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31193,36 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4 /* System */) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - 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); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4 /* System */); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.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 @@ -30677,15 +31230,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 208 /* VariableDeclaration */) { + if (root.kind === 209 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135 /* Parameter */) { + else if (root.kind === 136 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178 /* BinaryExpression */) { + if (root.kind === 179 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -30696,11 +31249,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -30716,7 +31269,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66 /* Identifier */) { + if (expr.kind !== 67 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -30731,23 +31284,23 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7 /* NumericLiteral */); + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); node.text = "" + value; return node; } @@ -30756,14 +31309,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66 /* Identifier */) { + if (syntheticName.kind !== 67 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); + var call = ts.createSynthesizedNode(166 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -30779,7 +31332,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -30794,8 +31347,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -30805,14 +31358,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161 /* ArrayLiteralExpression */) { + else if (target.kind === 162 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -30822,18 +31375,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write(")"); } } @@ -30857,12 +31413,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* 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 !== 184 /* OmittedExpression */) { + else if (element.kind !== 185 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -30881,7 +31437,7 @@ var ts; function emitVariableDeclaration(node) { if (ts.isBindingPattern(node.name)) { if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, false); + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); } else { emit(node.name); @@ -30901,15 +31457,15 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 197 /* ForInStatement */ && - node.parent.parent.kind !== 198 /* ForOfStatement */) { + node.parent.parent.kind !== 198 /* ForInStatement */ && + node.parent.parent.kind !== 199 /* ForOfStatement */) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -30920,11 +31476,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184 /* OmittedExpression */) { + if (node.kind === 185 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -30932,7 +31488,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -30940,7 +31496,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 245 /* SourceFile */; + node.parent.kind === 246 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31029,7 +31585,7 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); } else { emit(tempParameters[tempIndex]); @@ -31049,9 +31605,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31627,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31648,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,27 +31657,27 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170 /* FunctionExpression */) { + if (node.kind === 171 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* 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 */; } @@ -31130,10 +31686,25 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { - // Methods will emit the comments as part of emitting method declaration + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && + node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && + node.parent.kind !== 166 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression emitLeadingComments(node); } + emitStart(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)) { @@ -31153,10 +31724,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + emitEnd(node); + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31174,7 +31746,7 @@ var ts; if (node) { var parameters = node.parameters; var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); decreaseIndent(); @@ -31189,7 +31761,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var isArrowFunction = node.kind === 172 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -31310,7 +31882,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +31937,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 168 /* TypeAssertionExpression */) { + while (current.kind === 169 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -31388,7 +31960,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +31971,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +31988,7 @@ var ts; 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); + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); emitFunctionBodyPreamble(node); decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; @@ -31426,29 +31998,29 @@ var ts; write(" "); emit(statement); } - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); emitLeadingCommentsOfPosition(body.statements.end); } else { increaseIndent(); emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15 /* CloseBraceToken */, body.statements.end); + emitToken(16 /* CloseBraceToken */, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192 /* ExpressionStatement */) { + if (statement && statement.kind === 193 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 165 /* CallExpression */) { + if (expr && expr.kind === 166 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 92 /* SuperKeyword */) { + if (func && func.kind === 93 /* SuperKeyword */) { return statement; } } @@ -31472,25 +32044,27 @@ var ts; }); } 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 */) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133 /* ComputedPropertyName */) { + else if (memberName.kind === 134 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -31530,11 +32104,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188 /* SemicolonClassElement */) { + if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { + else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -31546,14 +32120,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { + else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -31603,22 +32175,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { + if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 /* MethodDeclaration */ || - member.kind === 142 /* GetAccessor */ || - member.kind === 143 /* SetAccessor */) { + else if (member.kind === 141 /* MethodDeclaration */ || + member.kind === 143 /* GetAccessor */ || + member.kind === 144 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 142 /* GetAccessor */) { + if (member.kind === 143 /* GetAccessor */) { write("get "); } - else if (member.kind === 143 /* SetAccessor */) { + else if (member.kind === 144 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -31629,7 +32201,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32226,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && !member.body) { + if (member.kind === 142 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -31697,18 +32269,23 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -31729,21 +32306,21 @@ var ts; emitEnd(baseTypeElement); } } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); if (ctor) { var statements = ctor.body.statements; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -31766,7 +32343,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* 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: @@ -31845,8 +32422,8 @@ 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 === 183 /* ClassExpression */; + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -31874,7 +32451,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* 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 @@ -31897,7 +32474,7 @@ var ts; var property = staticProperties[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); } write(","); writeLine(); @@ -31930,7 +32507,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -31965,23 +32542,23 @@ var ts; writeLine(); emitConstructor(node, baseTypeNode); emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end, function () { + emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -31989,11 +32566,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -32007,7 +32584,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32613,13 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); @@ -32085,7 +32662,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 140 /* MethodDeclaration */) { + if (member.kind === 141 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32123,7 +32700,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32138,7 +32715,7 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); @@ -32153,7 +32730,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32176,7 +32753,7 @@ var ts; var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); write("__param(" + parameterIndex + ", "); emit(decorator.expression); @@ -32195,10 +32772,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 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: return true; } return false; @@ -32208,7 +32785,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 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: return true; } return false; @@ -32218,9 +32795,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 211 /* ClassDeclaration */: - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return true; } return false; @@ -32238,19 +32815,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: write("Function"); return; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 135 /* Parameter */: + case 136 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32261,43 +32838,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: write("void 0"); return; - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: write("Function"); return; - case 153 /* ArrayType */: - case 154 /* TupleType */: + case 154 /* ArrayType */: + case 155 /* TupleType */: write("Array"); return; - case 147 /* TypePredicate */: - case 117 /* BooleanKeyword */: + case 148 /* TypePredicate */: + case 118 /* BooleanKeyword */: write("Boolean"); return; - case 127 /* StringKeyword */: - case 8 /* StringLiteral */: + case 128 /* StringKeyword */: + case 9 /* StringLiteral */: write("String"); return; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: write("Number"); return; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: write("Symbol"); return; - case 148 /* TypeReference */: + case 149 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 151 /* TypeQuery */: - case 152 /* TypeLiteral */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 114 /* AnyKeyword */: + case 152 /* TypeQuery */: + case 153 /* TypeLiteral */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 115 /* AnyKeyword */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -32307,21 +32887,27 @@ var ts; } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0 /* Auto */); write("(typeof ("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(typeName, true); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); write(") || Object"); break; case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); + emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; case ts.TypeReferenceSerializationKind.VoidType: write("void 0"); @@ -32364,7 +32950,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -32380,10 +32966,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153 /* ArrayType */) { + if (parameterType.kind === 154 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -32401,7 +32987,7 @@ var ts; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -32482,7 +33068,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -32543,7 +33129,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -32579,7 +33165,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216 /* ModuleBlock */) { + if (node.body.kind === 217 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -32598,7 +33184,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -32612,7 +33198,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -32624,29 +33210,45 @@ var ts; emitExportMemberAssignments(node.name); } } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8 /* StringLiteral */) { + if (moduleName.kind === 9 /* StringLiteral */) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17 /* CloseParenToken */, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -32661,7 +33263,7 @@ var ts; // ES6 import if (node.importClause) { var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -32674,7 +33276,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -32700,7 +33302,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -32719,7 +33321,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -32770,16 +33372,33 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } } - else if (!(node.flags & 1 /* Export */)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -32808,11 +33427,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -32835,7 +33454,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33466,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33481,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -32883,8 +33498,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 /* FunctionDeclaration */ && - expression.kind !== 211 /* ClassDeclaration */) { + if (expression.kind !== 211 /* FunctionDeclaration */ && + expression.kind !== 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -32898,6 +33513,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33536,9 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" // import x from "mod" where x is referenced // import * as x from "mod" where x is referenced @@ -32930,13 +33546,13 @@ var ts; externalImports.push(node); } break; - case 218 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 219 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -32957,7 +33573,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33599,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - return getLiteralText(moduleName); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -33006,8 +33622,8 @@ var ts; 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 === 225 /* ExportDeclaration */ || - (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 226 /* ExportDeclaration */ || + (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33040,14 +33656,14 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } } if (!hasExportDeclarationWithExportClause) { // we still need to emit exportStar helper - return emitExportStarFunction(undefined); + return emitExportStarFunction(/*localNames*/ undefined); } } var exportedNamesStorageRef = makeUniqueName("exportedNames"); @@ -33072,7 +33688,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225 /* ExportDeclaration */) { + if (externalImport.kind !== 226 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33097,6 +33713,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33722,12 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); @@ -33116,7 +33736,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33127,8 +33747,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33776,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 /* Identifier */ + var name_25 = local.kind === 67 /* Identifier */ ? local : local.name; if (name_25) { @@ -33172,13 +33792,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { + if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33206,21 +33826,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214 /* EnumDeclaration */) { + if (node.kind === 215 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33229,7 +33849,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33858,10 @@ var ts; } return; } - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { - if (shouldHoistVariable(node, false)) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_26 = node.name; - if (name_26.kind === 66 /* Identifier */) { + if (name_26.kind === 67 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } @@ -33253,6 +33873,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -33272,12 +33899,12 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: // function (exports) { // @@ -33322,105 +33949,86 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219 /* ImportDeclaration */: - if (!importNode.importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - // fall-through - case 218 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 /* 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); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 219 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 /* ImportDeclaration */ && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221 /* NamespaceImport */) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments(namedBindings.name); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } 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 225 /* 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("\"]);"); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -33432,17 +34040,33 @@ var ts; 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 225 /* ExportDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 210 /* FunctionDeclaration */: + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: continue; + case 226 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -33467,8 +34091,20 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -33477,8 +34113,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34180,36 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, true); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); increaseIndent(); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); @@ -33579,8 +34219,8 @@ var ts; emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); @@ -33590,9 +34230,10 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); // Emit exportDefault if it exists will happen as part // or normal statement emit. } @@ -33618,7 +34259,7 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; var text = ts.getTextOfNode(node); var firstNonWhitespace = 0; @@ -33631,7 +34272,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -33644,15 +34285,26 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -33666,13 +34318,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2 /* React */: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1 /* Preserve */: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -33681,9 +34333,9 @@ var ts; switch (compilerOptions.jsx) { case 1 /* Preserve */: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2 /* React */: emit(node.expression); @@ -33716,12 +34368,7 @@ var ts; } } } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. @@ -33746,6 +34393,14 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); @@ -33768,57 +34423,76 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2 /* Ambient */) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 225 /* ExportAssignment */: + return true; } } 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 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 224 /* ExportAssignment */: - return false; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(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 !== 189 /* Block */ && + if (node.kind !== 190 /* Block */ && node.parent && - node.parent.kind === 171 /* ArrowFunction */ && + node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -33829,170 +34503,170 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return emitIdentifier(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return emitParameter(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return emitMethod(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessor(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return emitThis(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return emitSuper(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return write("null"); - case 96 /* TrueKeyword */: + case 97 /* TrueKeyword */: return write("true"); - case 81 /* FalseKeyword */: + case 82 /* 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 */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: return emitLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return emitTemplateExpression(node); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return emitTemplateSpan(node); - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 233 /* JsxText */: + case 234 /* JsxText */: return emitJsxText(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return emitJsxExpression(node); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ObjectBindingPattern */: + case 159 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 159 /* ArrayBindingPattern */: + case 160 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return emitBindingElement(node); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 243 /* ShorthandPropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 165 /* CallExpression */: + case 166 /* CallExpression */: return emitCallExpression(node); - case 166 /* NewExpression */: + case 167 /* NewExpression */: return emitNewExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return emit(node.expression); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return emit(node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return emitParenExpression(node); - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return emitDeleteExpression(node); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return emitVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return emitAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return emitBinaryExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return emitConditionalExpression(node); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return emitYieldExpression(node); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return; - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return emitBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitVariableStatement(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: return write(";"); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return emitExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return emitIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return emitDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return emitWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return emitForStatement(node); - case 198 /* ForOfStatement */: - case 197 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 198 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return emitReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return emitWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return emitSwitchStatement(node); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return emitLabelledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return emitThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return emitTryStatement(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return emitCatchClause(node); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return emitClassExpression(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return emitClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMember(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return emitImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34010,6 +34684,11 @@ var ts; } return leadingComments; } + /** + * Removes all but the pinned or triple slash comments. + * @param ranges The array to be filtered + * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed. + */ function filterComments(ranges, onlyPinnedOrTripleSlashComments) { // If we're removing comments, then we want to strip out all but the pinned or // triple slash comments. @@ -34024,7 +34703,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 === 245 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34039,16 +34718,16 @@ 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 === 245 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); } function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { // If the caller only wants pinned or triple slash comments, then always filter @@ -34056,13 +34735,23 @@ var ts; 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); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ 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); + var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitLeadingCommentsOfPosition(pos) { var leadingComments; @@ -34077,7 +34766,7 @@ var ts; 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); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); @@ -34107,7 +34796,7 @@ var ts; if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -34119,6 +34808,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; @@ -34139,6 +34834,261 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// @@ -34149,7 +35099,8 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -34166,6 +35117,53 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + // TODO: use different resolution strategy based on compiler options + return legacyNameResolver(moduleName, containingFile, compilerOptions, host); + } + ts.resolveModuleName = resolveModuleName; + function legacyNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35229,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -34266,7 +35266,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -34277,18 +35277,37 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -34321,6 +35340,71 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -34334,10 +35418,10 @@ var ts; }; } function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken) { var _this = this; @@ -34347,7 +35431,7 @@ var ts; // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -34358,7 +35442,7 @@ var ts; // 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. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -34449,14 +35533,59 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* 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. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -34487,8 +35616,8 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); @@ -34496,22 +35625,22 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, false); + return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); } // We haven't looked for this file, do so now and cache result var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -34522,11 +35651,12 @@ var ts; skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -34542,7 +35672,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -34550,57 +35685,31 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 /* 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. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -34656,28 +35765,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -34685,17 +35794,21 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { @@ -34721,7 +35834,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); @@ -34738,16 +35851,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2 /* ES6 */) { @@ -34879,6 +35998,13 @@ var ts; { name: "out", type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -35088,7 +36214,7 @@ var ts; * @param fileName The path to the config file */ function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -35172,6 +36298,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -35250,7 +36379,7 @@ var ts; } else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); singleLineCommentCount = 0; lastSingleLineCommentEnd = -1; isFirstSingleLineComment = true; @@ -35267,11 +36396,11 @@ var ts; end: end, kind: 2 /* SingleLineCommentTrivia */ }; - addOutliningSpanComments(multipleSingleLineComments, false); + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -35283,34 +36412,34 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189 /* Block */: + case 190 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 194 /* DoStatement */ || - parent_8.kind === 197 /* ForInStatement */ || - parent_8.kind === 198 /* ForOfStatement */ || - parent_8.kind === 196 /* ForStatement */ || - parent_8.kind === 193 /* IfStatement */ || - parent_8.kind === 195 /* WhileStatement */ || - parent_8.kind === 202 /* WithStatement */ || - parent_8.kind === 241 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_7.kind === 195 /* DoStatement */ || + parent_7.kind === 198 /* ForInStatement */ || + parent_7.kind === 199 /* ForOfStatement */ || + parent_7.kind === 197 /* ForStatement */ || + parent_7.kind === 194 /* IfStatement */ || + parent_7.kind === 196 /* WhileStatement */ || + parent_7.kind === 203 /* WithStatement */ || + parent_7.kind === 242 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206 /* TryStatement */) { + if (parent_7.kind === 207 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -35329,25 +36458,25 @@ var ts; break; } // Fallthrough. - case 216 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 217 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 217 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 218 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); + case 162 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -35422,9 +36551,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -35436,8 +36565,8 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); + else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { // Don't know how to add this. @@ -35457,12 +36586,12 @@ var ts; } return true; } - if (expression.kind === 163 /* PropertyAccessExpression */) { + if (expression.kind === 164 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); } return false; } @@ -35470,8 +36599,8 @@ 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 === 133 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } } @@ -35546,17 +36675,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* 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 === 215 /* ModuleDeclaration */); + } while (current.kind === 216 /* ModuleDeclaration */); // fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -35567,21 +36696,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 225 /* ExportDeclaration */: + case 226 /* 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 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35593,7 +36722,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -35602,21 +36731,21 @@ var ts; } } break; - case 160 /* BindingElement */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: childNodes.push(node); break; } @@ -35664,17 +36793,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -35685,12 +36814,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -35750,7 +36879,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +36887,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* CallSignature */: + case 145 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: var variableDeclarationNode; var name_29; - if (node.kind === 160 /* BindingElement */) { + if (node.kind === 161 /* BindingElement */) { name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -35806,13 +36935,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141 /* Constructor */: + case 142 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -35842,29 +36971,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: return createSourceFileItem(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return createClassItem(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return createEnumItem(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return createModuleItem(node); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 8 /* StringLiteral */) { + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { return getTextOfNode(moduleDeclaration.name); } // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -35876,7 +37005,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 === 189 /* Block */) { + if (node.body && node.body.kind === 190 /* 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)); } @@ -35897,7 +37026,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* 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 @@ -35921,7 +37050,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -35930,13 +37059,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215 /* ModuleDeclaration */) { + while (node.body.kind === 216 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 /* SourceFile */ + return node.kind === 246 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -36039,12 +37168,12 @@ var ts; if (chunk.text.length === candidate.length) { // a) Check if the part matches the candidate entirely, in an case insensitive or // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); } else { // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -36060,9 +37189,9 @@ var ts; var wordSpans = getWordSpans(candidate); for (var _i = 0; _i < wordSpans.length; _i++) { var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, true)) { + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); } } } @@ -36072,20 +37201,20 @@ var ts; // candidate in a case *sensitive* manner. If so, return that there was a substring // match. if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); } } if (!isLowercase) { // e) If the part was not entirely lowercase, then attempt a camel cased match as well. if (chunk.characterSpans.length > 0) { var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); } } } @@ -36098,7 +37227,7 @@ var ts; // (Pattern: fogbar, Candidate: quuxfogbarFogBar). if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); } } } @@ -36122,7 +37251,7 @@ var ts; // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); if (match) { return [match]; } @@ -36168,7 +37297,7 @@ var ts; for (var _i = 0; _i < subWordTextChunks.length; _i++) { var subWordTextChunk = subWordTextChunks[_i]; // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, true); + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { return undefined; } @@ -36434,11 +37563,11 @@ var ts; }; } /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); + return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); + return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; function breakIntoSpans(identifier, word) { @@ -36731,15 +37860,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 /* Identifier */ + var name = expression.kind === 67 /* Identifier */ ? expression - : expression.kind === 163 /* PropertyAccessExpression */ + : expression.kind === 164 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -36772,7 +37901,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { + if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -36788,8 +37917,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 24 /* LessThanToken */ || - node.kind === 16 /* OpenParenToken */) { + if (node.kind === 25 /* LessThanToken */ || + node.kind === 17 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -36825,27 +37954,27 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* 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); + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -36873,7 +38002,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38021,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -36923,7 +38052,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 10 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -36945,7 +38074,7 @@ var ts; // The applicable span is from the first bar to the second bar (inclusive, // but not including parentheses) var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getApplicableSpanForTaggedTemplate(taggedTemplate) { @@ -36961,16 +38090,16 @@ 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 === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } } return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -37021,7 +38150,7 @@ var ts; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; @@ -37030,10 +38159,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -37044,10 +38173,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -37057,7 +38186,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -37081,12 +38210,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -37171,40 +38299,40 @@ var ts; return false; } switch (n.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 158 /* ObjectBindingPattern */: - case 152 /* TypeLiteral */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 217 /* CaseBlock */: - return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 241 /* CatchClause */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 159 /* ObjectBindingPattern */: + case 153 /* TypeLiteral */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 218 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 242 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 166 /* NewExpression */: + case 167 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: - case 157 /* ParenthesizedType */: - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: + case 158 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -37213,64 +38341,64 @@ 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 215 /* ModuleDeclaration */: + return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); + case 216 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 193 /* IfStatement */: + case 194 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 161 /* ArrayLiteralExpression */: - case 159 /* ArrayBindingPattern */: - case 164 /* ElementAccessExpression */: - case 133 /* ComputedPropertyName */: - case 154 /* TupleType */: - return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 146 /* IndexSignature */: + case 162 /* ArrayLiteralExpression */: + case 160 /* ArrayBindingPattern */: + case 165 /* ElementAccessExpression */: + case 134 /* ComputedPropertyName */: + case 155 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 147 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 173 /* TypeOfExpression */: - case 172 /* DeleteExpression */: - case 174 /* VoidExpression */: - case 181 /* YieldExpression */: - case 182 /* SpreadElementExpression */: + case 174 /* TypeOfExpression */: + case 173 /* DeleteExpression */: + case 175 /* VoidExpression */: + case 182 /* YieldExpression */: + case 183 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -37288,7 +38416,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -37326,7 +38454,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 === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -37351,12 +38479,12 @@ var ts; ts.getTouchingPropertyName = getTouchingPropertyName; /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, true, undefined); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ @@ -37436,7 +38564,7 @@ var ts; return n; } var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } function find(n) { @@ -37450,7 +38578,7 @@ var ts; if (position <= child.end) { if (child.getStart(sourceFile) >= position) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, i); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); return candidate && findRightmostToken(candidate); } else { @@ -37460,13 +38588,13 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 246 /* 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. // Namely we are skipping the check: 'position < node.end' if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } } @@ -37480,6 +38608,54 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. // Note, that getWidth() does not take trivia into account. @@ -37506,32 +38682,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { + if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 /* Identifier */ || ts.isKeyword(kind); + return kind === 67 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 /* StringLiteral */ || kind === 7 /* NumericLiteral */ || isWord(kind); + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); } function isComment(kind) { return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -37541,9 +38717,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: return true; } return false; @@ -37571,7 +38747,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -37706,6 +38882,14 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -37750,7 +38934,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -37778,7 +38962,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -37848,25 +39032,25 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28 /* GreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanToken */: + case 29 /* GreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanToken */: return true; } } return false; } function shouldRescanSlashToken(container) { - return container.kind === 9 /* RegularExpressionLiteral */; + return container.kind === 10 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 12 /* TemplateMiddle */ || - container.kind === 13 /* TemplateTail */; + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; + return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -37902,7 +39086,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -37912,7 +39096,7 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 15 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } @@ -38041,8 +39225,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -38233,112 +39417,112 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for indexer and dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space before and after indexer + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* 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([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* 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 */)); // TypeScript-specific higher priority rules // 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(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* 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([122 /* ModuleKeyword */, 124 /* 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([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* 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([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* 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([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* 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([81 /* ExtendsKeyword */, 104 /* 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 */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* 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([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* 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([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38378,6 +39562,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39573,8 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally @@ -38398,35 +39583,41 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function //TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenParenToken */, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -38441,38 +39632,38 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 196 /* ForStatement */; + return context.contextNode.kind === 197 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 186 /* AsExpression */: - case 147 /* TypePredicate */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 187 /* AsExpression */: + case 148 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 160 /* BindingElement */: + case 161 /* BindingElement */: // equals in type X = ... - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: // equal in p = 0; - case 135 /* Parameter */: - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; + case 136 /* Parameter */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 197 /* ForInStatement */: - return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; + case 198 /* ForInStatement */: + return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 198 /* ForOfStatement */: - return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; + case 199 /* ForOfStatement */: + return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; } return false; }; @@ -38480,7 +39671,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179 /* ConditionalExpression */; + return context.contextNode.kind === 180 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -38524,98 +39715,98 @@ var ts; return true; } switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 162 /* ObjectLiteralExpression */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 163 /* ObjectLiteralExpression */: + case 217 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 144 /* CallSignature */: - case 170 /* FunctionExpression */: - case 141 /* Constructor */: - case 171 /* ArrowFunction */: + case 145 /* CallSignature */: + case 171 /* FunctionExpression */: + case 142 /* Constructor */: + case 172 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; + return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 215 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 216 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211 /* ClassDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 189 /* Block */: - case 241 /* CatchClause */: - case 216 /* ModuleBlock */: - case 203 /* SwitchStatement */: + case 212 /* ClassDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 190 /* Block */: + case 242 /* CatchClause */: + case 217 /* ModuleBlock */: + case 204 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193 /* IfStatement */: - case 203 /* SwitchStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 206 /* TryStatement */: - case 194 /* DoStatement */: - case 202 /* WithStatement */: + case 194 /* IfStatement */: + case 204 /* SwitchStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 207 /* TryStatement */: + case 195 /* DoStatement */: + case 203 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 241 /* CatchClause */: + case 242 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162 /* ObjectLiteralExpression */; + return context.contextNode.kind === 163 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165 /* CallExpression */; + return context.contextNode.kind === 166 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166 /* NewExpression */; + return context.contextNode.kind === 167 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23 /* CommaToken */; + return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -38633,52 +39824,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136 /* Decorator */; + return node.kind === 137 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 210 /* 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 === 215 /* ModuleDeclaration */; + return context.contextNode.kind === 216 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 148 /* TypeReference */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 149 /* TypeReference */: + case 169 /* TypeAssertionExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 186 /* ExpressionWithTypeArguments */: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; + return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -38702,7 +39899,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 /* LastToken */ + 1; + this.mapRowLength = 132 /* 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); @@ -38897,7 +40094,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { result.push(token); } return result; @@ -38939,17 +40136,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -39027,6 +40224,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -39085,11 +40292,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -39153,17 +40360,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 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 245 /* SourceFile */: - case 189 /* Block */: - case 216 /* ModuleBlock */: + return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 246 /* SourceFile */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -39336,9 +40543,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 245 /* SourceFile */ || - parent.kind === 238 /* CaseClause */ || - parent.kind === 239 /* DefaultClause */) { + parent.kind === 246 /* SourceFile */ || + parent.kind === 239 /* CaseClause */ || + parent.kind === 240 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -39374,19 +40581,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; - case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; - case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; - case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; - case 142 /* GetAccessor */: return 120 /* GetKeyword */; - case 143 /* SetAccessor */: return 126 /* SetKeyword */; - case 140 /* MethodDeclaration */: + case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; + case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; + case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; + case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; + case 143 /* GetAccessor */: return 121 /* GetKeyword */; + case 144 /* SetAccessor */: return 127 /* SetKeyword */; + case 141 /* MethodDeclaration */: if (node.asteriskToken) { - return 36 /* AsteriskToken */; + return 37 /* AsteriskToken */; } // fall-through - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: return node.name.kind; } } @@ -39398,8 +40605,8 @@ var ts; // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: return indentation + delta; } return indentation; @@ -39413,15 +40620,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 14 /* OpenBraceToken */: - case 15 /* CloseBraceToken */: - case 18 /* OpenBracketToken */: - case 19 /* CloseBracketToken */: - case 16 /* OpenParenToken */: - case 17 /* CloseParenToken */: - case 77 /* ElseKeyword */: - case 101 /* WhileKeyword */: - case 53 /* AtToken */: + case 15 /* OpenBraceToken */: + case 16 /* CloseBraceToken */: + case 19 /* OpenBracketToken */: + case 20 /* CloseBracketToken */: + case 17 /* OpenParenToken */: + case 18 /* CloseParenToken */: + case 78 /* ElseKeyword */: + case 102 /* WhileKeyword */: + case 54 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -39468,7 +40675,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -39521,7 +40728,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -39556,7 +40763,7 @@ var ts; var inheritedIndentation = -1 /* Unknown */; for (var _i = 0; _i < nodes.length; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { if (formattingScanner.isOnToken()) { @@ -39614,13 +40821,13 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2 /* SingleLineCommentTrivia */: if (indentNextTokenOrTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } break; @@ -39683,7 +40890,7 @@ var ts; // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(false); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { @@ -39692,7 +40899,7 @@ var ts; // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(true); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -39732,7 +40939,7 @@ var ts; if (startLine === endLine) { if (!firstLineIsIndented) { // treat as single line comment - insertIndentation(commentRange.pos, indentation, false); + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); } return; } @@ -39844,49 +41051,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141 /* Constructor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 172 /* ArrowFunction */: if (node.typeParameters === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.parameters === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.arguments === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16 /* OpenParenToken */: - return 17 /* CloseParenToken */; - case 24 /* LessThanToken */: - return 26 /* GreaterThanToken */; + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -39963,17 +41170,17 @@ var ts; return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 8 /* StringLiteral */ || - precedingToken.kind === 9 /* RegularExpressionLiteral */ || - precedingToken.kind === 10 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 11 /* TemplateHead */ || - precedingToken.kind === 12 /* TemplateMiddle */ || - precedingToken.kind === 13 /* TemplateTail */; + var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || + precedingToken.kind === 10 /* RegularExpressionLiteral */ || + precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || + precedingToken.kind === 12 /* TemplateHead */ || + precedingToken.kind === 13 /* TemplateMiddle */ || + precedingToken.kind === 14 /* TemplateTail */; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* 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 */) { @@ -40013,12 +41220,12 @@ var ts; // no parent was found - return 0 to be indented on the level of SourceFile return 0; } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { @@ -40092,7 +41299,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 === 245 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -40103,11 +41310,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14 /* OpenBraceToken */) { + if (nextToken.kind === 15 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 15 /* CloseBraceToken */) { + else if (nextToken.kind === 16 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -40125,8 +41332,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); + if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -40137,23 +41344,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return node.parent.properties; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return node.parent.elements; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: { + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -40164,8 +41371,8 @@ var ts; } break; } - case 166 /* NewExpression */: - case 165 /* CallExpression */: { + case 167 /* NewExpression */: + case 166 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -40192,11 +41399,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 17 /* CloseParenToken */) { + if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 165 /* CallExpression */ || - node.parent.kind === 166 /* NewExpression */) && + if (node.parent && (node.parent.kind === 166 /* CallExpression */ || + node.parent.kind === 167 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -40214,10 +41421,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: node = node.expression; break; default: @@ -40234,7 +41441,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23 /* CommaToken */) { + if (list[i].kind === 24 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -40282,28 +41489,30 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 161 /* ArrayLiteralExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 162 /* ObjectLiteralExpression */: - case 152 /* TypeLiteral */: - case 154 /* TupleType */: - case 217 /* CaseBlock */: - case 239 /* DefaultClause */: - case 238 /* CaseClause */: - case 169 /* ParenthesizedExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 190 /* VariableStatement */: - case 208 /* VariableDeclaration */: - case 224 /* ExportAssignment */: - case 201 /* ReturnStatement */: - case 179 /* ConditionalExpression */: - case 159 /* ArrayBindingPattern */: - case 158 /* ObjectBindingPattern */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 162 /* ArrayLiteralExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 163 /* ObjectLiteralExpression */: + case 153 /* TypeLiteral */: + case 155 /* TupleType */: + case 218 /* CaseBlock */: + case 240 /* DefaultClause */: + case 239 /* CaseClause */: + case 170 /* ParenthesizedExpression */: + case 164 /* PropertyAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 191 /* VariableStatement */: + case 209 /* VariableDeclaration */: + case 225 /* ExportAssignment */: + case 202 /* ReturnStatement */: + case 180 /* ConditionalExpression */: + case 160 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 231 /* JsxElement */: return true; } return false; @@ -40313,22 +41522,22 @@ var ts; return true; } switch (parent) { - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - return child !== 189 /* Block */; + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,7 +41589,7 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); @@ -40431,7 +41640,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -40450,7 +41659,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132 /* FirstNode */) { + if (this.kind >= 133 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -40492,24 +41701,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -40550,15 +41755,15 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration, indexOfDeclaration) { // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times + // In case of union property there might be same declaration multiple times // which only varies in type parameter // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming + // The property length will have two declarations of property length coming // from Array - Array and Array 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 === 135 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -40567,15 +41772,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { + if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { + while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -40588,7 +41793,7 @@ var ts; return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { return { pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator + end: jsDocComment.end - "*/".length // Trim off comment end indicator }; }); } @@ -40690,7 +41895,7 @@ var ts; if (isParamTag(pos, end, sourceFile)) { var blankLineCount = 0; var recordedParamTag = false; - // Consume leading spaces + // Consume leading spaces pos = consumeWhiteSpaces(pos + paramTag.length); if (pos >= end) { break; @@ -40740,7 +41945,7 @@ var ts; var firstLineParamHelpStringPos = pos; while (pos < end) { var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line + // at line break, set this comment line text and go to next line if (ts.isLineBreak(ch)) { if (paramHelpString) { pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); @@ -40793,7 +41998,7 @@ var ts; if (paramHelpStringMargin === undefined) { paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; } - // Now consume white spaces max + // Now consume white spaces max var startOfLinePos = pos; pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); if (pos >= end) { @@ -40843,6 +42048,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -40914,9 +42124,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133 /* ComputedPropertyName */) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -40926,9 +42136,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -40936,9 +42146,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -40958,60 +42168,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 152 /* TypeLiteral */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 153 /* TypeLiteral */: addDeclaration(node); // fall through - case 141 /* Constructor */: - case 190 /* VariableStatement */: - case 209 /* VariableDeclarationList */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 216 /* ModuleBlock */: + case 142 /* Constructor */: + case 191 /* VariableStatement */: + case 210 /* VariableDeclarationList */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 217 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135 /* Parameter */: + case 136 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: addDeclaration(node); break; - case 225 /* ExportDeclaration */: + case 226 /* 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 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -41023,7 +42233,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -41227,16 +42437,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 170 /* FunctionExpression */) { + if (declaration.kind === 171 /* FunctionExpression */) { return true; } - if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { + if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { + if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { return false; } } @@ -41253,8 +42463,8 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { @@ -41331,7 +42541,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -41356,52 +42566,76 @@ var ts; /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used bu this function are: + * Extra compiler options that will unconditionally be used by this function are: * - isolatedModules = true * - allowNonTsExtensions = true * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, + // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. options.noLib = true; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; // Parse - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); // Output var outputText; + var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -41415,7 +42649,7 @@ var ts; ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; ts.disableIncrementalParsing = false; function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then + // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. if (textChangeRange) { if (version !== sourceFile.version) { @@ -41461,7 +42695,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames) { @@ -41469,13 +42703,14 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -41506,18 +42741,18 @@ var ts; return JSON.stringify(bucketInfoArray, null, 2); } function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); } function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, true); + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -41526,7 +42761,7 @@ var ts; bucket.set(fileName, entry); } else { - // We have an entry for this file. However, it may be for a different version of + // We have an entry for this file. However, it may be for a different version of // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { @@ -41565,6 +42800,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -41580,6 +42816,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41603,31 +42845,42 @@ var ts; // export * from "mod" // export {a as b} from "mod" while (token !== 1 /* EndOfFileToken */) { - if (token === 86 /* ImportKeyword */) { + if (token === 120 /* DeclareKeyword */) { + // declare module "mod" token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 123 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { // import "mod"; recordModuleName(); continue; } else { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import d from "mod"; recordModuleName(); continue; } } - else if (token === 54 /* EqualsToken */) { + else if (token === 55 /* EqualsToken */) { token = scanner.scan(); - if (token === 124 /* RequireKeyword */) { + if (token === 125 /* RequireKeyword */) { token = scanner.scan(); - if (token === 16 /* OpenParenToken */) { + if (token === 17 /* OpenParenToken */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import i = require("mod"); recordModuleName(); continue; @@ -41635,7 +42888,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +42897,17 @@ var ts; continue; } } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -41662,15 +42915,15 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { token = scanner.scan(); - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -41681,19 +42934,19 @@ var ts; } } } - else if (token === 79 /* ExportKeyword */) { + else if (token === 80 /* ExportKeyword */) { token = scanner.scan(); - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -41701,11 +42954,11 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export * from "mod" recordModuleName(); } @@ -41720,13 +42973,13 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -41734,13 +42987,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 /* Identifier */ && - (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && + return node.kind === 67 /* Identifier */ && + (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 /* Identifier */ && - node.parent.kind === 204 /* LabeledStatement */ && + return node.kind === 67 /* Identifier */ && + node.parent.kind === 205 /* LabeledStatement */ && node.parent.label === node; } /** @@ -41748,7 +43001,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -41759,56 +43012,56 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** 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 === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 215 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 216 /* ModuleDeclaration */: return node.parent.name === node; - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -41860,7 +43113,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { + for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -41875,17 +43128,17 @@ var ts; return undefined; } switch (node.kind) { - case 245 /* SourceFile */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: return node; } } @@ -41893,38 +43146,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 208 /* VariableDeclaration */: + case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 209 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 244 /* EnumMember */: return ScriptElementKind.variableElement; - case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 220 /* ImportClause */: - case 227 /* ExportSpecifier */: - case 221 /* NamespaceImport */: + case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 245 /* EnumMember */: return ScriptElementKind.variableElement; + case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 228 /* ExportSpecifier */: + case 222 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -41995,26 +43248,44 @@ var ts; if (programUpToDate()) { return; } - // IMPORTANT - It is critical from this moment onward that we do not check + // IMPORTANT - It is critical from this moment onward that we do not check // cancellation tokens. We are about to mutate source files from a previous program // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of + // the program points to old source files that have been invalidated because of // incremental parsing. var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); // Now create a new compiler - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); - // Release any files we have acquired in the old program but are + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + // Release any files we have acquired in the old program but are // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); @@ -42030,7 +43301,7 @@ var ts; // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent + // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. program.getTypeChecker(); return; @@ -42050,7 +43321,7 @@ var ts; // Check if the old program had this file already var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to + // We already had a source file for this file name. Go to the registry to // ensure that we get the right up to date version of it. We need this to // address the following 'race'. Specifically, say we have the following: // @@ -42061,15 +43332,15 @@ var ts; // LS2 // // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will // have version 1. And *importantly* this source file will be *corrupt*. // The act of creating version 2 of the file irrevocably damages the version // 1 file. // // So, later when we call into LS1, we need to make sure that it doesn't use // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the + // either version 1, version 2 (or some other version) depending on what the // host says should be used. return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } @@ -42128,7 +43399,7 @@ var ts; synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a + // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. if (ts.isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); @@ -42152,44 +43423,44 @@ var ts; return false; } switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 103 /* ImplementsKeyword */) { + if (heritageClause.token === 104 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -42197,20 +43468,20 @@ var ts; return true; } break; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -42218,7 +43489,7 @@ var ts; return true; } break; - case 135 /* Parameter */: + case 136 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -42234,17 +43505,17 @@ var ts; return true; } break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168 /* TypeAssertionExpression */: + case 169 /* 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 136 /* Decorator */: + case 137 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -42270,18 +43541,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 119 /* DeclareKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 120 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 110 /* StaticKeyword */: - case 79 /* ExportKeyword */: - case 71 /* ConstKeyword */: - case 74 /* DefaultKeyword */: - case 112 /* AbstractKeyword */: + case 111 /* StaticKeyword */: + case 80 /* ExportKeyword */: + case 72 /* ConstKeyword */: + case 75 /* DefaultKeyword */: + case 113 /* AbstractKeyword */: } } } @@ -42380,13 +43651,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20 /* DotToken */) { - if (parent_10.kind === 163 /* PropertyAccessExpression */) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 164 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132 /* QualifiedName */) { + else if (parent_9.kind === 133 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -42396,7 +43667,7 @@ var ts; return undefined; } } - else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { isRightOfOpenTag = true; location = contextToken; } @@ -42433,7 +43704,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { + if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -42462,7 +43733,7 @@ var ts; } } if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that + // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part @@ -42489,7 +43760,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -42510,10 +43781,10 @@ var ts; // aggregating completion candidates. This is achieved in 'getScopeNode' // by finding the first node that encompasses a position, accounting for whether a node // is "complete" to decide whether a position belongs to the node. - // + // // However, at the end of an identifier, we are interested in the scope of the identifier // itself, but fall outside of the identifier. For instance: - // + // // xyz => x$ // // the cursor is outside of both the 'x' and the arrow function 'xyz => x', @@ -42563,41 +43834,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 165 /* CallExpression */ // func( a, | - || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 166 /* NewExpression */ // new C(a, | - || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| - case 16 /* OpenParenToken */: - return containingNodeKind === 165 /* CallExpression */ // func( | - || containingNodeKind === 141 /* Constructor */ // constructor( | - || containingNodeKind === 166 /* NewExpression */ // new C(a| - || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 18 /* OpenBracketToken */: - return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 122 /* ModuleKeyword */: // module | - case 123 /* NamespaceKeyword */: + case 24 /* CommaToken */: + return containingNodeKind === 166 /* CallExpression */ // func( a, | + || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 167 /* NewExpression */ // new C(a, | + || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 166 /* CallExpression */ // func( | + || containingNodeKind === 142 /* Constructor */ // constructor( | + || containingNodeKind === 167 /* NewExpression */ // new C(a| + || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 123 /* ModuleKeyword */: // module | + case 124 /* NamespaceKeyword */: return true; - case 20 /* DotToken */: - return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| - case 14 /* OpenBraceToken */: - return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | - case 54 /* EqualsToken */: - return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 178 /* BinaryExpression */; // x = a| - case 11 /* TemplateHead */: - return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| - case 12 /* TemplateMiddle */: - return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | + case 21 /* DotToken */: + return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | + case 55 /* EqualsToken */: + return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 179 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -42610,8 +43881,8 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 /* StringLiteral */ - || contextToken.kind === 9 /* RegularExpressionLiteral */ + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -42624,7 +43895,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +43911,29 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -42682,9 +43964,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? - 219 /* ImportDeclaration */ : - 225 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? + 220 /* ImportDeclaration */ : + 226 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -42707,11 +43989,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // let x = { | - case 23 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { - return parent_11; + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + return parent_10; } break; } @@ -42725,11 +44007,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // import { | - case 23 /* CommaToken */: + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return contextToken.parent; } } @@ -42738,24 +44020,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25 /* LessThanSlashToken */: - case 37 /* SlashToken */: - case 66 /* Identifier */: - if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { - return parent_12; + case 26 /* LessThanSlashToken */: + case 38 /* SlashToken */: + case 67 /* Identifier */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + return parent_11; } break; - case 15 /* CloseBraceToken */: - // The context token is the closing } of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - if (parent_12 && - parent_12.kind === 237 /* JsxExpression */ && - parent_12.parent && - parent_12.parent.kind === 235 /* JsxAttribute */) { - return parent_12.parent.parent; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 238 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 236 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + return parent_11.parent; } break; } @@ -42764,16 +44056,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return true; } return false; @@ -42784,65 +44076,65 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 208 /* VariableDeclaration */ || - containingNodeKind === 209 /* VariableDeclarationList */ || - containingNodeKind === 190 /* VariableStatement */ || - containingNodeKind === 214 /* EnumDeclaration */ || + case 24 /* CommaToken */: + return containingNodeKind === 209 /* VariableDeclaration */ || + containingNodeKind === 210 /* VariableDeclarationList */ || + containingNodeKind === 191 /* VariableStatement */ || + containingNodeKind === 215 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| - case 20 /* DotToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| - case 52 /* ColonToken */: - return containingNodeKind === 160 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 241 /* CatchClause */ || + containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 211 /* FunctionDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */; // var [x, y| + case 21 /* DotToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| + case 53 /* ColonToken */: + return containingNodeKind === 161 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 242 /* CatchClause */ || isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 214 /* EnumDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* TypeLiteral */; // let x : { | - case 22 /* SemicolonToken */: - return containingNodeKind === 137 /* PropertySignature */ && + case 15 /* OpenBraceToken */: + return containingNodeKind === 215 /* EnumDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 153 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 138 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 211 /* FunctionDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || isFunction(containingNodeKind); - case 110 /* StaticKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 135 /* Parameter */ || + case 111 /* StaticKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 136 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 135 /* Parameter */; - case 113 /* AsKeyword */: - containingNodeKind === 223 /* ImportSpecifier */ || - containingNodeKind === 227 /* ExportSpecifier */ || - containingNodeKind === 221 /* NamespaceImport */; - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 104 /* InterfaceKeyword */: - case 84 /* FunctionKeyword */: - case 99 /* VarKeyword */: - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - case 86 /* ImportKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 111 /* YieldKeyword */: - case 129 /* TypeKeyword */: + contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 136 /* Parameter */; + case 114 /* AsKeyword */: + containingNodeKind === 224 /* ImportSpecifier */ || + containingNodeKind === 228 /* ExportSpecifier */ || + containingNodeKind === 222 /* NamespaceImport */; + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 105 /* InterfaceKeyword */: + case 85 /* FunctionKeyword */: + case 100 /* VarKeyword */: + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + case 87 /* ImportKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 112 /* YieldKeyword */: + case 130 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -42861,7 +44153,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7 /* NumericLiteral */) { + if (contextToken.kind === 8 /* NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -42906,9 +44198,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 242 /* PropertyAssignment */ && - m.kind !== 243 /* ShorthandPropertyAssignment */ && - m.kind !== 160 /* BindingElement */) { + if (m.kind !== 243 /* PropertyAssignment */ && + m.kind !== 244 /* ShorthandPropertyAssignment */ && + m.kind !== 161 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -42916,7 +44208,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 160 /* BindingElement */ && m.propertyName) { + if (m.kind === 161 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -42943,7 +44235,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235 /* JsxAttribute */) { + if (attr.kind === 236 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -42983,7 +44275,7 @@ var ts; for (var name_32 in nameTable) { if (!allNames[name_32]) { allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); if (displayName) { var entry = { name: displayName, @@ -42999,17 +44291,17 @@ var ts; return entries; } function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); if (!displayName) { return undefined; } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what + // that a suggestion for a value is an interface. We COULD also just do what // 'getSymbolModifiers' does, which is to use the first declaration. // Use a 'sortText' of 0' so that all symbol completion entries come before any other // entries (like JavaScript identifier entries). @@ -43049,10 +44341,10 @@ var ts; var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); if (symbol) { var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { @@ -43081,7 +44373,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -43145,7 +44437,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - // If this was union of all methods, + // If this was union of all methods, //make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { @@ -43183,7 +44475,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 164 /* 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)) { @@ -43192,7 +44484,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { + if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -43205,10 +44497,10 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -43222,7 +44514,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -43238,14 +44530,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -43257,24 +44549,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { + (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141 /* Constructor */) { + if (functionDeclaration.kind === 142 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -43283,7 +44575,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -43291,7 +44583,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -43299,48 +44591,48 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87 /* InKeyword */)); + displayParts.push(ts.keywordPart(88 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -43349,13 +44641,13 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -43364,11 +44656,11 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244 /* EnumMember */) { + if (declaration.kind === 245 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -43376,26 +44668,26 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218 /* ImportEqualsDeclaration */) { + if (declaration.kind === 219 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -43412,7 +44704,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -43450,7 +44742,7 @@ var ts; } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -43471,9 +44763,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); return; } } @@ -43481,12 +44773,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(34 /* PlusToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(35 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -43512,11 +44804,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -43560,7 +44852,7 @@ var ts; 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. + // Just add all the declarations. ts.forEach(declarations, function (declaration) { result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); @@ -43569,18 +44861,18 @@ var ts; 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 === 118 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 212 /* ClassDeclaration */); + return tryAddSignature(classDeclaration.members, /*selectConstructors*/ 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 tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); } return false; } @@ -43588,8 +44880,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141 /* Constructor */) || - (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 142 /* Constructor */) || + (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -43618,7 +44910,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } /// Triple slash reference comments var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); @@ -43649,16 +44941,16 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 66 /* Identifier */ && node.parent === declaration) { + if (node.kind === 67 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // 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 === 243 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -43692,7 +44984,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -43706,7 +44998,7 @@ var ts; var results = getOccurrencesAtPositionCore(fileName, position); if (results) { var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So + // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); } @@ -43732,12 +45024,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 94 /* ThisKeyword */ || - node.kind === 92 /* SuperKeyword */ || + if (node.kind === 67 /* Identifier */ || + node.kind === 95 /* ThisKeyword */ || + node.kind === 93 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -43785,77 +45077,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85 /* IfKeyword */: - case 77 /* ElseKeyword */: - if (hasKind(node.parent, 193 /* IfStatement */)) { + case 86 /* IfKeyword */: + case 78 /* ElseKeyword */: + if (hasKind(node.parent, 194 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 91 /* ReturnKeyword */: - if (hasKind(node.parent, 201 /* ReturnStatement */)) { + case 92 /* ReturnKeyword */: + if (hasKind(node.parent, 202 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 95 /* ThrowKeyword */: - if (hasKind(node.parent, 205 /* ThrowStatement */)) { + case 96 /* ThrowKeyword */: + if (hasKind(node.parent, 206 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 69 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { + case 70 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97 /* TryKeyword */: - case 82 /* FinallyKeyword */: - if (hasKind(parent(node), 206 /* TryStatement */)) { + case 98 /* TryKeyword */: + case 83 /* FinallyKeyword */: + if (hasKind(parent(node), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93 /* SwitchKeyword */: - if (hasKind(node.parent, 203 /* SwitchStatement */)) { + case 94 /* SwitchKeyword */: + if (hasKind(node.parent, 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68 /* CaseKeyword */: - case 74 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { + case 69 /* CaseKeyword */: + case 75 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67 /* BreakKeyword */: - case 72 /* ContinueKeyword */: - if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68 /* BreakKeyword */: + case 73 /* ContinueKeyword */: + if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83 /* ForKeyword */: - if (hasKind(node.parent, 196 /* ForStatement */) || - hasKind(node.parent, 197 /* ForInStatement */) || - hasKind(node.parent, 198 /* ForOfStatement */)) { + case 84 /* ForKeyword */: + if (hasKind(node.parent, 197 /* ForStatement */) || + hasKind(node.parent, 198 /* ForInStatement */) || + hasKind(node.parent, 199 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101 /* WhileKeyword */: - case 76 /* DoKeyword */: - if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { + case 102 /* WhileKeyword */: + case 77 /* DoKeyword */: + if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118 /* ConstructorKeyword */: - if (hasKind(node.parent, 141 /* Constructor */)) { + case 119 /* ConstructorKeyword */: + if (hasKind(node.parent, 142 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -43871,10 +45163,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* ThrowStatement */) { + if (node.kind === 206 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 206 /* TryStatement */) { + else if (node.kind === 207 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -43902,19 +45194,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + return parent_12; } // 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_13.kind === 206 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_12.kind === 207 /* TryStatement */) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -43923,7 +45215,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { + if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -43939,16 +45231,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203 /* SwitchStatement */: - if (statement.kind === 199 /* ContinueStatement */) { + case 204 /* SwitchStatement */: + if (statement.kind === 200 /* ContinueStatement */) { continue; } // Fall through. - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -43967,24 +45259,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 /* ClassDeclaration */ || - container.kind === 183 /* ClassExpression */ || - (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { + if (!(container.kind === 212 /* ClassDeclaration */ || + container.kind === 184 /* ClassExpression */ || + (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { return undefined; } } - else if (modifier === 110 /* StaticKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { + else if (modifier === 111 /* StaticKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { return undefined; } } - else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { - if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { + else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { + if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { return undefined; } } - else if (modifier === 112 /* AbstractKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + else if (modifier === 113 /* AbstractKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { return undefined; } } @@ -43996,8 +45288,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216 /* ModuleBlock */: - case 245 /* SourceFile */: + case 217 /* ModuleBlock */: + case 246 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -44006,17 +45298,17 @@ var ts; nodes = container.statements; } break; - case 141 /* Constructor */: + case 142 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -44037,19 +45329,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109 /* PublicKeyword */: + case 110 /* PublicKeyword */: return 16 /* Public */; - case 107 /* PrivateKeyword */: + case 108 /* PrivateKeyword */: return 32 /* Private */; - case 108 /* ProtectedKeyword */: + case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: return 128 /* Static */; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -44069,13 +45361,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* 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, 120 /* GetKeyword */, 126 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); } } } @@ -44084,19 +45376,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 194 /* DoStatement */) { + if (loopNode.kind === 195 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { break; } } @@ -44105,22 +45397,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -44128,14 +45420,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); } }); }); @@ -44143,13 +45435,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -44160,13 +45452,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -44174,36 +45466,36 @@ 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, 189 /* Block */))) { + if (!(func && hasKind(func.body, 190 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -44212,7 +45504,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -44279,11 +45571,11 @@ var ts; return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } @@ -44294,7 +45586,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 /* Identifier */ && + if (node.kind !== 67 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -44302,7 +45594,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -44320,10 +45612,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94 /* ThisKeyword */) { + if (node.kind === 95 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92 /* SuperKeyword */) { + if (node.kind === 93 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -44383,7 +45675,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; + return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -44410,14 +45702,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -44443,7 +45735,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 246 /* 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; @@ -44471,12 +45763,12 @@ var ts; // If we are past the end, stop looking if (position > end) break; - // We found a match. Make sure it's not part of a larger word (i.e. the char + // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { - // Found a real match. Keep searching. + // Found a real match. Keep searching. positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -44514,16 +45806,16 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return node.getWidth() === searchSymbolName.length; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { // For string literals we have two additional chars for the quotes return node.getWidth() === searchSymbolName.length + 2; } break; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -44547,11 +45839,11 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a + // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like @@ -44600,44 +45892,29 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 /* StringLiteral */ && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // Then we want to make sure that it wasn't in a "///<" directive comment - // We don't want to unintentionally update a file name. - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); if (!searchSpaceNode) { return undefined; } // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -44650,10 +45927,10 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92 /* SuperKeyword */) { + if (!node || node.kind !== 93 /* SuperKeyword */) { return; } - var container = ts.getSuperContainer(node, false); + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. @@ -44665,31 +45942,31 @@ var ts; return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 171 /* 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. @@ -44698,7 +45975,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245 /* SourceFile */) { + if (searchSpaceNode.kind === 246 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -44724,32 +46001,32 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94 /* ThisKeyword */) { + if (!node || node.kind !== 95 /* ThisKeyword */) { return; } - var container = ts.getThisContainer(node, false); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211 /* ClassDeclaration */: + case 212 /* 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 245 /* SourceFile */: - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + case 246 /* SourceFile */: + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -44803,11 +46080,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 === 211 /* ClassDeclaration */) { + if (declaration.kind === 212 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212 /* InterfaceDeclaration */) { + else if (declaration.kind === 213 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -44839,7 +46116,7 @@ var ts; return aliasedSymbol; } } - // If the reference location is in an object literal, try to get the contextual type for the + // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol if (isNameOfPropertyAssignment(referenceLocation)) { @@ -44854,7 +46131,7 @@ var ts; if (searchSymbols.indexOf(rootSymbol) >= 0) { return rootSymbol; } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; @@ -44930,7 +46207,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { start += 1; end -= 1; } @@ -44942,17 +46219,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { + if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; + return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; } } return false; @@ -44984,34 +46261,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 241 /* CatchClause */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 242 /* CatchClause */: return 1 /* Value */; - case 134 /* TypeParameter */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 152 /* TypeLiteral */: + case 135 /* TypeParameter */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 153 /* TypeLiteral */: return 2 /* Type */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 215 /* ModuleDeclaration */: - if (node.name.kind === 8 /* StringLiteral */) { + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -45020,15 +46297,15 @@ var ts; else { return 4 /* Namespace */; } - case 222 /* NamedImports */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 219 /* ImportDeclaration */: - case 224 /* ExportAssignment */: - case 225 /* ExportDeclaration */: + case 223 /* NamedImports */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 220 /* ImportDeclaration */: + case 225 /* ExportAssignment */: + case 226 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 245 /* SourceFile */: + case 246 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -45038,8 +46315,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 /* TypeReference */ || - (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 /* TypeReference */ || + (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -45047,50 +46324,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { + if (root.parent.kind === 164 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || - (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); + return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || + (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132 /* QualifiedName */) { - while (root.parent && root.parent.kind === 132 /* QualifiedName */) { + if (root.parent.kind === 133 /* QualifiedName */) { + while (root.parent && root.parent.kind === 133 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 /* TypeReference */ && !isLastClause; + return root.parent.kind === 149 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132 /* QualifiedName */) { + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 132 /* QualifiedName */ && + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224 /* ExportAssignment */) { + if (node.parent.kind === 225 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -45130,15 +46407,15 @@ var ts; return; } switch (node.kind) { - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 8 /* StringLiteral */: - case 81 /* FalseKeyword */: - case 96 /* TrueKeyword */: - case 90 /* NullKeyword */: - case 92 /* SuperKeyword */: - case 94 /* ThisKeyword */: - case 66 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 9 /* StringLiteral */: + case 82 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 91 /* NullKeyword */: + case 93 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 67 /* Identifier */: break; // Cant create the text span default: @@ -45152,9 +46429,9 @@ var ts; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { // 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 + // 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 === 215 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -45188,17 +46465,17 @@ var ts; // been canceled. That would be an enormous amount of chattyness, along with the all // the overhead of marshalling the data to/from the host. So instead we pick a few // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent + // constructs that we would expect to see commonly, but just at a far less frequent // interval. // // For example, in checker.ts (around 750k) we only have around 600 of these constructs. // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -45252,7 +46529,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 /* ModuleDeclaration */ && + return declaration.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -45262,7 +46539,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -45323,8 +46600,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -45355,13 +46632,13 @@ var ts; // Only bother with the trivia if it at least intersects the span of interest. if (ts.isComment(kind)) { classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner + // Classifying a comment might cause us to reuse the trivia scanner // (because of jsdoc comments). So after we classify the comment make // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { + if (kind === 7 /* ConflictMarkerTrivia */) { var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments @@ -45399,7 +46676,7 @@ var ts; for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { var tag = _a[_i]; // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. + // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } @@ -45407,16 +46684,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -45451,7 +46728,7 @@ var ts; } } function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex + // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. for (var i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { @@ -45487,7 +46764,7 @@ var ts; } } } - // for accurate classification, the actual token should be passed in. however, for + // 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, token) { @@ -45496,7 +46773,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { // 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)) { @@ -45505,30 +46782,30 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54 /* EqualsToken */) { + if (tokenKind === 55 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 208 /* VariableDeclaration */ || - token.parent.kind === 138 /* PropertyDeclaration */ || - token.parent.kind === 135 /* Parameter */) { + if (token.parent.kind === 209 /* VariableDeclaration */ || + token.parent.kind === 139 /* PropertyDeclaration */ || + token.parent.kind === 136 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 178 /* BinaryExpression */ || - token.parent.kind === 176 /* PrefixUnaryExpression */ || - token.parent.kind === 177 /* PostfixUnaryExpression */ || - token.parent.kind === 179 /* ConditionalExpression */) { + if (token.parent.kind === 179 /* BinaryExpression */ || + token.parent.kind === 177 /* PrefixUnaryExpression */ || + token.parent.kind === 178 /* PostfixUnaryExpression */ || + token.parent.kind === 180 /* ConditionalExpression */) { return 5 /* operator */; } } return 10 /* punctuation */; } - else if (tokenKind === 7 /* NumericLiteral */) { + else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 8 /* StringLiteral */) { + else if (tokenKind === 9 /* StringLiteral */) { return 6 /* stringLiteral */; } - else if (tokenKind === 9 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -45536,35 +46813,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 66 /* Identifier */) { + else if (tokenKind === 67 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 135 /* Parameter */: + case 136 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -45630,14 +46907,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; - case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; - case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; - case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; - case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; - case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; + case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; + case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; + case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; + case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; + case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; + case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; + case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; } return undefined; } @@ -45672,12 +46949,73 @@ var ts; } return []; } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a function declaration. + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - methods + // - constructors + // - class decls + var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; + }, ""); + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually + // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call // this on every single file. If we treat this syntactically, then that will cause // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing + // treating this as a semantic operation, we can access any tree without throwing // anything away. synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -45701,7 +47039,7 @@ var ts; // 0) The full match for the entire regexp. // 1) The preamble to the message portion. // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each + // 3...N) The descriptor that was matched - by index. 'undefined' for each // descriptor that didn't match. an actual value if it did match. // // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. @@ -45723,7 +47061,7 @@ var ts; } } ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non + // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; @@ -45768,10 +47106,10 @@ var ts; // (?:(TODO\(jason\))|(HACK)) // // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after + // *are* capture groups. By capturing the inner literals we can determine after // matching which descriptor we are dealing with. var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the + // After matching a descriptor literal, the following regexp matches the rest of the // text up to the end of the line (or */). var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; @@ -45802,7 +47140,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 66 /* Identifier */) { + if (node && node.kind === 67 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -45882,6 +47220,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47241,17 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: nameTable[node.text] = node.text; break; - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: // We want to store any numbers/strings if they were a name that could be // related to a declaration. So, if we have 'import x = require("something")' // 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 === 229 /* ExternalModuleReference */ || + node.parent.kind === 230 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -45925,29 +47264,29 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 /* ElementAccessExpression */ && + node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where - /// we have a series of divide operator. this list allows us to be more accurate by ruling out + /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[66 /* Identifier */] = true; - noRegexTable[8 /* StringLiteral */] = true; - noRegexTable[7 /* NumericLiteral */] = true; - noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[94 /* ThisKeyword */] = true; - noRegexTable[39 /* PlusPlusToken */] = true; - noRegexTable[40 /* MinusMinusToken */] = true; - noRegexTable[17 /* CloseParenToken */] = true; - noRegexTable[19 /* CloseBracketToken */] = true; - noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[96 /* TrueKeyword */] = true; - noRegexTable[81 /* FalseKeyword */] = true; + noRegexTable[67 /* Identifier */] = true; + noRegexTable[9 /* StringLiteral */] = true; + noRegexTable[8 /* NumericLiteral */] = true; + noRegexTable[10 /* RegularExpressionLiteral */] = true; + noRegexTable[95 /* ThisKeyword */] = true; + noRegexTable[40 /* PlusPlusToken */] = true; + noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[18 /* CloseParenToken */] = true; + noRegexTable[20 /* CloseBracketToken */] = true; + noRegexTable[16 /* CloseBraceToken */] = true; + noRegexTable[97 /* TrueKeyword */] = true; + noRegexTable[82 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -45972,11 +47311,11 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 /* GetKeyword */ || - keyword2 === 126 /* SetKeyword */ || - keyword2 === 118 /* ConstructorKeyword */ || - keyword2 === 110 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". + if (keyword2 === 121 /* GetKeyword */ || + keyword2 === 127 /* SetKeyword */ || + keyword2 === 119 /* ConstructorKeyword */ || + keyword2 === 111 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; } @@ -45994,7 +47333,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -46003,8 +47342,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -46074,7 +47413,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47432,83 @@ var ts; // token. So the classification will go back to being an identifier. The moment the user // types again, number will become a keyword, then an identifier, etc. etc. // - // To try to avoid this problem, we avoid classifying contextual keywords as keywords + // To try to avoid this problem, we avoid classifying contextual keywords as keywords // when the user is potentially typing something generic. We just can't do a good enough // job at the lexical level, and so well leave it up to the syntactic classifier to make // the determination. // - // In order to determine if the user is potentially typing something generic, we use a + // In order to determine if the user is potentially typing something generic, we use a // weak heuristic where we track < and > tokens. It's a weak heuristic, but should // work well enough in practice. var angleBracketStack = 0; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { - token = 9 /* RegularExpressionLiteral */; + if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + token = 10 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 66 /* Identifier */; + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 67 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if + // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } - else if (lastNonTriviaToken === 66 /* Identifier */ && - token === 24 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping + else if (lastNonTriviaToken === 67 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 114 /* AnyKeyword */ || - token === 127 /* StringKeyword */ || - token === 125 /* NumberKeyword */ || - token === 117 /* BooleanKeyword */ || - token === 128 /* SymbolKeyword */) { + else if (token === 115 /* AnyKeyword */ || + token === 128 /* StringKeyword */ || + token === 126 /* NumberKeyword */ || + token === 118 /* BooleanKeyword */ || + token === 129 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this + // 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, // causing a noisy experience for the user. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } } - else if (token === 11 /* TemplateHead */) { + else if (token === 12 /* TemplateHead */) { templateStack.push(token); } - else if (token === 14 /* OpenBraceToken */) { + else if (token === 15 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15 /* CloseBraceToken */) { + else if (token === 16 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11 /* TemplateHead */) { + if (lastTemplateStackToken === 12 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 12 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -46184,7 +47523,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -46210,10 +47549,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 10 /* NoSubstitutionTemplateLiteral */) { + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -46221,7 +47560,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -46232,8 +47571,8 @@ var ts; 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 + // 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; } @@ -46251,42 +47590,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: - case 44 /* AmpersandToken */: - case 46 /* CaretToken */: - case 45 /* BarToken */: - case 49 /* AmpersandAmpersandToken */: - case 50 /* BarBarToken */: - case 64 /* BarEqualsToken */: - case 63 /* AmpersandEqualsToken */: - case 65 /* CaretEqualsToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 55 /* PlusEqualsToken */: - case 56 /* MinusEqualsToken */: - case 57 /* AsteriskEqualsToken */: - case 58 /* SlashEqualsToken */: - case 59 /* PercentEqualsToken */: - case 54 /* EqualsToken */: - case 23 /* CommaToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + case 45 /* AmpersandToken */: + case 47 /* CaretToken */: + case 46 /* BarToken */: + case 50 /* AmpersandAmpersandToken */: + case 51 /* BarBarToken */: + case 65 /* BarEqualsToken */: + case 64 /* AmpersandEqualsToken */: + case 66 /* CaretEqualsToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 56 /* PlusEqualsToken */: + case 57 /* MinusEqualsToken */: + case 58 /* AsteriskEqualsToken */: + case 59 /* SlashEqualsToken */: + case 60 /* PercentEqualsToken */: + case 55 /* EqualsToken */: + case 24 /* CommaToken */: return true; default: return false; @@ -46294,19 +47633,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; + return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -46315,24 +47654,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; - case 6 /* ConflictMarkerTrivia */: + case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 66 /* Identifier */: + case 67 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -46364,7 +47703,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -46434,159 +47773,159 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ForStatement */) { + if (node.parent.kind === 197 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 172 /* 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 190 /* VariableStatement */: + case 191 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208 /* VariableDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 209 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return spanInVariableDeclaration(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return spanInParameterDeclaration(node); - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: return spanInBlock(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInBlock(node.block); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 193 /* IfStatement */: + case 194 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInForStatement(node); - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 206 /* TryStatement */: + case 207 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: // span on complete node return textSpan(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23 /* CommaToken */: + case 24 /* CommaToken */: return spanInPreviousNode(node); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 15 /* CloseBraceToken */: + case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return spanInOpenParenToken(node); - case 17 /* CloseParenToken */: + case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 52 /* ColonToken */: + case 53 /* ColonToken */: return spanInColonToken(node); - case 26 /* GreaterThanToken */: - case 24 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return spanInWhileKeyword(node); - case 77 /* ElseKeyword */: - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 78 /* ElseKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -46599,12 +47938,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -46658,7 +47997,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); + (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -46681,18 +48020,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 195 /* WhileStatement */: - case 193 /* IfStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 194 /* IfStatement */: + case 198 /* ForInStatement */: + case 199 /* 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 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -46700,7 +48039,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -46720,13 +48059,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -46734,25 +48073,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 214 /* EnumDeclaration */: - case 211 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -46766,7 +48105,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -46776,17 +48115,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: - case 196 /* ForStatement */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: + case 197 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -46797,19 +48136,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168 /* TypeAssertionExpression */) { + if (node.parent.kind === 169 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -46878,9 +48217,18 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + // if shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -46988,10 +48336,26 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -47098,7 +48462,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -47131,9 +48495,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -47270,7 +48631,10 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; /// COMPLETION LISTS @@ -47318,6 +48682,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { @@ -47401,12 +48769,20 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -47530,4 +48906,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.5"; +var toolsVersion = "1.6";