diff --git a/Jakefile.js b/Jakefile.js index 396f15e2730..ea13cce6685 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -143,7 +143,8 @@ var harnessSources = harnessCoreSources.concat([ "convertToBase64.ts", "transpile.ts", "reuseProgramStructure.ts", - "cachingInServerLSHost.ts" + "cachingInServerLSHost.ts", + "moduleResolution.ts" ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ @@ -157,10 +158,10 @@ var harnessSources = harnessCoreSources.concat([ var librarySourceMap = [ { target: "lib.core.d.ts", sources: ["core.d.ts"] }, - { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, - { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, + { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, + { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, { target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], }, - { target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, + { target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, { target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]}, { target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }, ]; diff --git a/README.md b/README.md index c8bc5936c24..c474f62fb4c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang). +[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). ## Installing 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..c55970d9aca 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. @@ -6592,6 +6929,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -6706,7 +7044,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 { @@ -7579,7 +7917,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -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; @@ -11379,7 +11719,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -12121,7 +12461,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -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; @@ -16293,12 +16633,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -16453,7 +16813,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; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 5ec268b2fd5..54461afef40 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. @@ -5409,6 +3105,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -5523,7 +3220,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 { @@ -6396,7 +4093,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -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; @@ -10196,7 +7895,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -10938,7 +8637,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -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; @@ -15110,12 +12809,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -15270,7 +12989,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; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 6c06cc08dc7..de051a44edd 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. @@ -7964,6 +8217,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -8078,7 +8332,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 { @@ -8951,7 +9205,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -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; @@ -12751,7 +13007,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -13493,7 +13749,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -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; @@ -17665,12 +17921,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -17825,7 +18101,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; @@ -18011,6 +18287,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..0f3e85da9f1 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; @@ -3009,7 +776,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -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; @@ -3035,7 +829,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface WebSocket extends EventTarget { @@ -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,25 +1084,39 @@ 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; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + 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 +1130,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; diff --git a/lib/tsc.js b/lib/tsc.js index 185aca1ef44..0ccb839c2ef 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_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other 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,12 @@ 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}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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,11 +1566,13 @@ 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." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1613,7 +1613,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 +1622,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 +1839,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 +1905,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1963,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 +2020,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 +2111,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 +2150,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 +2291,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 +2465,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 +2497,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 +2540,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 +2643,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 +2655,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 +2665,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 +2675,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 +2691,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 +2703,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 +2726,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 +2746,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 +2812,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 +2871,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 +2893,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 +2909,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 +2984,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 +3009,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -3026,10 +3061,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 +3072,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 +3129,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 +3175,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 +3221,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 +3271,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 +3292,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 +3302,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 +3330,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 +3356,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 +3377,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 +3405,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 +3449,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 +3478,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 +3507,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,12 +3627,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -3637,7 +3680,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 +3742,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 +3789,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3791,7 +3865,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 +3880,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 +3899,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 +3937,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 +3974,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 +3986,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 +4008,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 +4029,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 +4101,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 +4127,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 +4158,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 +4173,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 +4249,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 +4290,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 +4325,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 +4338,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 +4346,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 +4390,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 +4405,93 @@ 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: + case 238: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4422,7 +4509,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 +4518,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 +4539,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 +4553,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 +4569,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 +4605,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 +4619,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 +4646,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 +4681,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 +4708,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 +4722,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 +4740,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 +4856,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 +4869,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 +4896,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 +4918,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 +5172,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 +5184,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 +5199,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 +5211,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 +5222,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 +5304,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 +5331,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 +5348,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 +5378,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 +5392,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 +5403,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 +5621,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 +5635,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 +5673,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 +5695,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 +5723,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 +5881,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 +6102,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 +6142,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 +6275,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 +6301,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 +6351,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 +6406,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 +6424,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 +6443,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 +6476,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 +6494,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 +6520,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 +6549,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 +6565,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6470,39 +6588,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 +6630,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6617,17 +6735,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 +6754,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6646,65 +6764,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 +6877,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 +6921,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 +6933,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 +6978,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 +6987,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 +7021,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 +7043,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 +7063,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 +7075,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6965,7 +7083,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 +7091,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 +7128,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 +7149,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 +7169,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 +7191,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 +7235,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 +7254,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 +7302,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 +7322,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 +7350,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 +7387,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 +7427,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 +7448,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 +7467,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 +7476,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 +7502,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 +7511,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7406,11 +7524,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 +7537,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 +7562,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 +7650,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 +7678,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 +7695,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 +7704,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 +7723,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 +7815,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7707,25 +7825,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 +7852,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 +7862,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7755,44 +7873,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 +7919,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7814,19 +7932,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 +7960,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 +8072,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 +8095,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 +8114,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 +8226,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 +8264,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 +8275,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 +8286,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 +8324,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 +8372,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 +8405,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 +8413,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 +8422,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 +8522,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 +8579,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 +8624,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 +8701,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 +8737,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 +8772,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 +8807,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 +8833,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 +8844,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 +8874,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 +8892,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 +8910,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 +8927,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8800,26 +8937,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 +8968,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 +9009,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 +9023,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 +9035,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 +9089,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 +9099,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 +9124,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 +9157,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 +9168,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 +9188,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 +9251,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 +9267,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 +9305,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 +9316,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 +9340,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 +9410,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 +9422,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 +9448,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 +9474,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 +9501,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 +9594,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9468,40 +9605,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 +9648,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 +9659,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 +9754,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 +9765,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 +9791,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); @@ -9694,7 +9831,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -9706,7 +9842,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 +9852,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 +9861,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 +9885,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 +9896,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 +9917,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 +9961,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9855,9 +9991,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 +10249,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 +10277,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 +10286,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 +10340,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10222,7 +10362,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10235,6 +10375,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10376,10 +10517,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 +10543,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 +10568,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 +10591,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 +10607,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 +10617,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 +10625,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 +10659,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 +10686,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 +10698,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 +10727,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 +10740,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 +10829,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 +10881,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 +10894,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 +10916,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 +10948,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 +11061,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 +11126,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 +11169,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 +11198,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 +11253,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 +11286,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 +11341,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 +11358,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 +11382,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11295,7 +11424,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 +11448,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 +11472,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 +11502,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 +11510,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 +11538,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11430,7 +11559,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 +11568,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 +11584,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,32 +11663,32 @@ 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) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -11568,7 +11697,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 +11705,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 +11785,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 +11799,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 +11847,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 +11915,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 +11945,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 +12019,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 +12032,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 +12053,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 +12065,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 +12081,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 +12113,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 +12128,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 + return pattern.kind === 159 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11983,15 +12138,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 +12156,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 +12184,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 +12197,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 +12227,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 +12316,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 +12327,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 +12371,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 +12440,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 +12484,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 +12518,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 +12685,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 +12874,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 +12891,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 +12972,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 +13046,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 +13070,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 +13092,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 +13102,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 +13121,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 +13147,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13001,7 +13203,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 +13217,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 +13246,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 +13271,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 +13299,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 +13372,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 +13398,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 +13473,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 +13499,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 +13583,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 +13605,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 +13632,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 +13668,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 +13765,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 +13774,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -13597,6 +13831,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } var result = createObjectType(65536 | 131072, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); @@ -13608,6 +13851,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -13635,27 +13879,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 +13973,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 +14172,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 +14359,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 +14388,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 +14500,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 +14513,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 +14537,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 +14614,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 +14645,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 +14711,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 +14755,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 +14799,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 +14813,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 +14841,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 +14877,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 +14903,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 +14930,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 +15080,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 +15123,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 +15142,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 +15205,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 +15246,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 +15297,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 +15330,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 +15361,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 +15393,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 +15424,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 +15450,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 +15461,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 +15498,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 +15612,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 +15645,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 +15654,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 +15674,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 +15682,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 +15774,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 +15784,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 +15802,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 +15848,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 +15856,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 +15870,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 +15892,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 +15921,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 +15933,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 +15944,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 +15959,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 +15977,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 +16003,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 +16014,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 +16043,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 +16079,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -15795,9 +16094,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 +16167,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 +16177,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 +16210,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 +16248,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 +16316,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 +16325,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 +16355,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 +16363,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 +16388,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16130,7 +16433,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 +16448,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 +16466,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 +16484,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 +16504,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 +16520,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 +16544,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 +16569,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 +16598,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 +16610,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 +16622,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 +16634,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 +16687,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 +16734,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 +16753,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 +16771,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 +16792,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 +16814,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 +16851,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 +16883,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 +16910,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 +16978,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 +17053,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 +17098,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 +17142,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 +17179,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 +17200,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 +17221,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 +17240,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 +17273,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 +17377,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 +17386,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 +17399,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 +17413,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 +17461,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 +17493,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 +17511,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 +17569,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 +17635,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 +17644,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 +17656,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 +17681,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 +17707,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 +17720,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 +17741,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 +17785,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 +17810,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 +17855,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 +17953,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 +17983,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -17671,9 +17991,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 +18006,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 +18102,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 +18117,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 +18135,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 +18167,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 +18177,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 +18213,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 +18238,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 +18253,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 +18261,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -17981,48 +18301,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 +18371,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 +18462,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 +18482,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 +18558,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 +18590,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 +18673,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 +18851,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,29 +18875,33 @@ 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))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } function checkTypeAnnotationAsExpression(node) { 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 +18924,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 +18964,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 +18999,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 +19021,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 +19047,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 +19068,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 +19081,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 +19096,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 +19106,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 +19124,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 +19153,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 +19162,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 +19190,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 +19213,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 +19246,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 +19266,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 +19287,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 +19297,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 +19459,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 +19477,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 +19513,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 +19525,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 +19542,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 +19568,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 +19636,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 +19789,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 +19830,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 +19896,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 +19914,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 +19946,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 +19962,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 +20007,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 +20051,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 +20078,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -19747,7 +20113,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 +20136,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 +20159,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 +20167,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 +20188,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 +20207,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 +20247,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 +20273,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -19942,7 +20308,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 +20324,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 +20338,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 +20352,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 +20377,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 +20417,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 +20601,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 +20700,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 +20722,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 +20776,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 +20823,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 +20835,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 +20868,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 +20940,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 +20963,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 +20971,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 +21037,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 +21054,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 +21084,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 +21110,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 +21147,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 +21161,17 @@ 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); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -20804,7 +21193,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 +21235,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 +21281,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -20973,7 +21363,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 +21373,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 +21419,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 +21443,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 +21456,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 +21475,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 +21488,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 +21535,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 +21550,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 +21568,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 +21583,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 +21634,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 +21651,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 +21686,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 +21718,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 +21745,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 +21758,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 +21773,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 +21789,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 +21827,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 +21878,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 +21890,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 +21899,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 +21939,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 +21967,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 +21977,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 +21996,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 +22023,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 +22033,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 +22047,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 +22065,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 +22074,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 +22094,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 +22103,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 +22120,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 +22144,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 +22163,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 +22206,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 +22226,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 +22241,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 +22255,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 +22274,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 +22347,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 +22420,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 +22434,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 +22442,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 +22534,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 +22665,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 +22683,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 +22701,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 +22713,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 +22731,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 +22761,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22420,7 +22808,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22446,7 +22834,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 +22890,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 +22907,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 +22955,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 +22965,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 +22983,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: @@ -22643,9 +23035,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91) { + write("null"); + } 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 +23120,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 +23138,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 +23153,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 +23179,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 +23245,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 +23258,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 +23267,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 +23313,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 +23340,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 +23353,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 +23377,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 +23401,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 +23414,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 +23442,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 +23464,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 +23487,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 +23499,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 +23510,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 +23534,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 +23559,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 +23600,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 +23656,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); @@ -23301,11 +23695,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; var exportFunctionForFile; var generatedNameSet = {}; @@ -23325,7 +23715,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 +23786,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 +23798,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 +23864,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 +23949,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 +23966,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 +24076,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 +24087,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -23710,7 +24103,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 +24213,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -23846,7 +24241,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 +24254,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 +24266,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 +24292,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 +24326,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 +24353,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 +24386,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 +24398,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 +24424,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 +24435,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 +24463,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 +24512,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 +24532,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 +24556,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 +24568,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 +24591,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 +24623,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24240,58 +24635,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 +24700,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 +24713,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); @@ -24334,17 +24731,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } 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; @@ -24359,6 +24761,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -24418,7 +24823,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24432,7 +24837,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24440,22 +24845,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 +24877,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 +24910,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24566,7 +24971,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 +25022,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 +25060,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 +25074,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 +25124,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 +25139,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 +25180,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 +25206,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 +25222,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 +25234,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -24832,16 +25249,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 +25273,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 +25293,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -24896,13 +25313,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 +25370,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 +25394,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 +25426,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 +25448,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 +25469,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 +25481,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 +25495,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 +25530,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 +25571,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 +25596,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 +25616,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 +25631,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 +25662,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 +25686,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 +25702,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 +25733,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 +25756,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25347,13 +25764,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 +25779,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25374,17 +25791,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 +25813,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 +25829,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 +25858,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 +25893,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 +25913,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 +25932,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 +25969,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25543,6 +25977,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25561,44 +25996,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 +26048,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 +26068,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66) { + if (expr.kind !== 67) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -25641,37 +26080,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 +26124,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 +26137,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 +26148,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 +26165,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 +26199,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 +26234,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 +26253,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 +26265,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 +26273,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 +26371,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -25950,7 +26392,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -25971,7 +26413,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -25980,26 +26422,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 +26449,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 +26472,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 +26508,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 +26551,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26153,10 +26599,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 +26668,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 +26702,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 +26759,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 +26775,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 +26830,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 +26856,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26433,10 +26877,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 +26911,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 +26952,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26513,7 +26960,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 +26983,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 +27000,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 +27027,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -26620,7 +27067,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -26658,7 +27105,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 +27117,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -26678,11 +27125,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 +27203,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 +27239,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 +27278,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 +27327,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 +27375,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 +27430,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 +27446,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 +27466,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27088,7 +27543,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27147,7 +27602,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 +27637,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 +27656,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27214,7 +27669,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 +27681,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 +27742,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 +27768,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 +27780,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27359,16 +27826,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 +27876,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 +27902,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27434,10 +27913,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27450,13 +27928,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 +27945,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 +27960,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27506,18 +27983,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 +28012,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27560,17 +28037,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 +28059,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 +28085,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 +28114,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 +28136,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -27666,17 +28145,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 +28168,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -27707,7 +28188,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 +28203,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 +28237,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 +28260,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -27788,10 +28269,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 +28284,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 +28305,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 +28319,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -27839,75 +28327,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 +28397,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 +28431,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 +28452,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -28012,6 +28512,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28031,6 +28532,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28039,6 +28541,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 +28561,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28083,9 +28587,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; for (var i = 0; i < text.length; i++) { @@ -28093,7 +28597,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 +28610,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 +28642,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 +28657,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28177,10 +28691,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 +28713,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 +28741,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 +28806,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 +28997,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 +29009,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 +29029,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 +29078,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,16 +29104,273 @@ 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 = {})); /// /// +/// var ts; (function (ts) { ts.programTime = 0; 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 +29387,172 @@ 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) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function useBaseUrl(moduleName) { + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(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 }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -28649,7 +29615,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 +29652,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 +29663,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 +29718,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 +29796,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 +29877,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 +29952,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 +29972,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 +29983,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 +30003,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 +30016,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 +30091,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 +30120,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 +30155,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 +30167,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) { @@ -29154,6 +30223,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -29244,6 +30318,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 @@ -29342,20 +30422,39 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2, + "classic": 1 + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -29446,7 +30545,7 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -29519,6 +30618,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 +30655,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 +30678,7 @@ var ts; if (!ts.sys.fileExists(filePath)) { return false; } - var fileContents = ''; + var fileContents = ""; try { fileContents = ts.sys.readFile(filePath); } @@ -29668,6 +30770,10 @@ var ts; reportDiagnostics(commandLine.errors); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } + if (commandLine.options.init) { + writeConfigFile(commandLine.options, commandLine.fileNames); + return ts.sys.exit(ts.ExitStatus.Success); + } if (commandLine.options.version) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version)); return ts.sys.exit(ts.ExitStatus.Success); @@ -29823,16 +30929,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 @@ -29910,5 +31015,60 @@ var ts; return Array(paddingLength + 1).join(" "); } } + function writeConfigFile(options, fileNames) { + var currentDirectory = ts.sys.getCurrentDirectory(); + var file = ts.combinePaths(currentDirectory, 'tsconfig.json'); + if (ts.sys.fileExists(file)) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + } + else { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions), + exclude: ["node_modules"] + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); + } + return; + function serializeCompilerOptions(options) { + var result = {}; + var optionsNameMap = ts.getOptionNameMap().optionNameMap; + for (var name_28 in options) { + if (ts.hasProperty(options, name_28)) { + var value = options[name_28]; + switch (name_28) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var optionDefinition = optionsNameMap[name_28.toLowerCase()]; + if (optionDefinition) { + if (typeof optionDefinition.type === "string") { + result[name_28] = value; + } + else { + var typeMap = optionDefinition.type; + for (var key in typeMap) { + if (ts.hasProperty(typeMap, key)) { + if (typeMap[key] === value) + result[name_28] = key; + } + } + } + } + break; + } + } + } + return result; + } + } })(ts || (ts = {})); ts.executeCommandLine(ts.sys.args); diff --git a/lib/tsserver.js b/lib/tsserver.js index 9d582485e2f..3c339e6d661 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_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other 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,12 @@ 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}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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,11 +1566,13 @@ 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." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1613,7 +1613,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 +1622,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 +1839,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 +1905,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1963,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 +2020,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 +2111,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 +2150,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 +2291,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 +2465,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 +2497,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 +2540,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 +2643,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 +2655,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 +2665,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 +2675,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 +2691,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 +2703,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 +2726,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 +2746,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 +2812,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 +2871,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 +2893,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 +2909,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); @@ -2975,6 +3010,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -3065,6 +3105,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 @@ -3163,20 +3209,39 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2, + "classic": 1 + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -3267,7 +3332,7 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -3340,6 +3405,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 +3484,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 +3531,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3508,7 +3607,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 +3622,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 +3641,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 +3679,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 +3716,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 +3728,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 +3750,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 +3771,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 +3843,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 +3869,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 +3900,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 +3915,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 +3991,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 +4032,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 +4067,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 +4080,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 +4088,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 +4132,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 +4147,93 @@ 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: + case 238: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4139,7 +4251,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 +4260,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 +4281,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 +4295,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 +4311,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 +4347,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 +4361,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 +4388,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 +4423,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 +4450,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 +4464,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 +4482,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 +4598,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 +4611,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 +4638,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 +4660,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 +4914,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 +4926,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 +4941,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 +4953,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 +4964,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 +5046,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 +5073,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 +5090,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 +5120,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 +5134,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 +5145,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 +5363,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 +5377,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 +5415,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 +5437,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 +5465,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 +5623,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 +5844,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 +5884,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 +6017,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 +6043,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 +6093,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 +6148,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 +6166,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 +6185,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 +6218,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 +6236,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 +6262,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 +6291,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 +6307,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6187,39 +6330,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 +6372,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6334,17 +6477,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 +6496,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6363,65 +6506,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 +6619,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 +6663,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 +6675,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 +6720,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 +6729,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 +6763,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 +6785,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 +6805,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 +6817,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6682,7 +6825,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 +6833,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 +6870,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 +6891,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 +6911,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 +6933,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 +6977,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 +6996,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 +7044,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 +7064,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 +7092,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 +7129,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 +7169,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 +7190,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 +7209,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 +7218,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 +7244,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 +7253,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7123,11 +7266,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 +7279,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 +7304,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 +7392,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 +7420,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 +7437,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 +7446,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 +7465,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 +7557,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7424,25 +7567,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 +7594,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 +7604,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7472,44 +7615,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 +7661,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7531,19 +7674,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 +7702,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 +7814,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 +7837,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 +7856,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 +7968,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 +8006,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 +8017,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 +8028,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 +8066,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 +8114,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 +8147,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 +8155,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 +8164,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 +8264,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 +8321,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 +8366,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 +8443,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 +8479,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 +8514,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 +8549,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 +8575,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 +8586,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 +8616,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 +8634,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 +8652,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 +8669,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8517,26 +8679,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 +8710,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 +8751,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 +8765,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 +8777,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 +8831,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 +8841,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 +8866,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 +8899,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 +8910,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 +8930,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 +8993,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 +9009,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 +9047,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 +9058,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 +9082,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 +9152,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 +9164,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 +9190,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 +9216,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 +9243,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 +9336,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9185,40 +9347,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 +9390,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 +9401,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 +9496,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 +9507,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 +9533,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); @@ -9411,7 +9573,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -9423,7 +9584,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 +9594,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 +9603,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 +9627,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 +9638,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 +9659,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 +9703,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9572,9 +9733,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 +9954,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 +9979,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -9870,10 +10031,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 +10042,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 +10099,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 +10145,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 +10191,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 +10241,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 +10262,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 +10272,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 +10300,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 +10326,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 +10347,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 +10375,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 +10419,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 +10448,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 +10477,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,12 +10597,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -10481,7 +10650,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 +10705,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 +10733,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 +10742,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 +10796,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10645,7 +10818,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10658,6 +10831,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10799,10 +10973,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 +10999,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 +11024,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 +11047,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 +11063,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 +11073,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 +11081,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 +11115,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 +11142,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 +11154,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 +11183,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 +11196,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 +11285,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 +11337,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 +11350,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 +11372,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 +11404,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 +11517,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 +11582,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 +11625,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 +11654,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 +11709,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 +11742,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 +11797,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 +11814,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 +11838,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11718,7 +11880,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 +11904,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 +11928,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 +11958,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 +11966,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 +11994,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11853,7 +12015,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 +12024,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 +12040,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,32 +12119,32 @@ 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) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -11991,7 +12153,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 +12161,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 +12241,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 +12255,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 +12303,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 +12371,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 +12401,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 +12475,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 +12488,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 +12509,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 +12521,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 +12537,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 +12569,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 +12584,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 + return pattern.kind === 159 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -12406,15 +12594,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 +12612,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 +12640,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 +12653,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 +12683,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 +12772,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 +12783,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 +12827,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 +12896,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 +12940,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 +12974,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 +13141,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 +13330,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 +13347,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 +13428,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 +13502,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 +13526,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 +13548,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 +13558,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 +13577,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 +13603,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13424,7 +13659,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 +13673,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 +13702,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 +13727,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 +13755,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 +13828,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 +13854,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 +13929,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 +13955,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 +14039,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 +14061,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 +14088,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 +14124,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 +14221,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 +14230,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -14020,6 +14287,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } var result = createObjectType(65536 | 131072, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); @@ -14031,6 +14307,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -14058,27 +14335,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 +14429,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 +14628,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 +14815,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 +14844,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 +14956,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 +14969,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 +14993,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 +15070,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 +15101,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 +15167,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 +15211,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 +15255,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 +15269,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 +15297,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 +15333,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 +15359,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 +15386,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 +15536,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 +15579,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 +15598,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 +15661,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 +15702,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 +15753,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 +15786,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 +15817,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 +15849,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 +15880,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 +15906,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 +15917,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 +15954,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 +16068,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 +16101,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 +16110,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 +16130,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 +16138,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 +16230,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 +16240,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 +16258,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 +16304,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 +16312,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 +16326,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 +16348,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 +16377,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 +16389,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 +16400,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 +16415,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 +16433,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 +16459,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 +16470,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 +16499,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 +16535,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -16218,9 +16550,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 +16623,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 +16633,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 +16666,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 +16704,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 +16772,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 +16781,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 +16811,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 +16819,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 +16844,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16553,7 +16889,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 +16904,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 +16922,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 +16940,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 +16960,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 +16976,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 +17000,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 +17025,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 +17054,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 +17066,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 +17078,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 +17090,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 +17143,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 +17190,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 +17209,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 +17227,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 +17248,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 +17270,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 +17307,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 +17339,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 +17366,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 +17434,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 +17509,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 +17554,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 +17598,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 +17635,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 +17656,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 +17677,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 +17696,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 +17729,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 +17833,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 +17842,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 +17855,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 +17869,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 +17917,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 +17949,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 +17967,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 +18025,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 +18091,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 +18100,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 +18112,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 +18137,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 +18163,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 +18176,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 +18197,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 +18241,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 +18266,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 +18311,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 +18409,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 +18439,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -18094,9 +18447,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 +18462,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 +18558,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 +18573,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 +18591,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 +18623,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 +18633,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 +18669,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 +18694,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 +18709,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 +18717,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18404,48 +18757,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 +18827,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 +18918,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 +18938,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 +19014,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 +19046,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 +19129,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 +19307,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,29 +19331,33 @@ 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))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } function checkTypeAnnotationAsExpression(node) { 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 +19380,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 +19420,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 +19455,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 +19477,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 +19503,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 +19524,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 +19537,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 +19552,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 +19562,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 +19580,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 +19609,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 +19618,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 +19646,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 +19669,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 +19702,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 +19722,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 +19743,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 +19753,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 +19915,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 +19933,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 +19969,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 +19981,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 +19998,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 +20024,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 +20092,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 +20245,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 +20286,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 +20352,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 +20370,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 +20402,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 +20418,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 +20463,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 +20507,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 +20534,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -20170,7 +20569,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 +20592,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 +20615,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 +20623,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 +20644,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 +20663,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 +20703,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 +20729,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -20365,7 +20764,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 +20780,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 +20794,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 +20808,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 +20833,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 +20873,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 +21057,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 +21156,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 +21178,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 +21232,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 +21279,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 +21291,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 +21324,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 +21396,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 +21419,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 +21427,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 +21493,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 +21510,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 +21540,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 +21566,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 +21603,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 +21617,17 @@ 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); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -21227,7 +21649,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 +21691,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 +21737,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -21396,7 +21819,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 +21829,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 +21875,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 +21899,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 +21912,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 +21931,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 +21944,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 +21991,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 +22006,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 +22024,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 +22039,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 +22090,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 +22107,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 +22142,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 +22174,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 +22201,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 +22214,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 +22229,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 +22245,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 +22283,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 +22334,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 +22346,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 +22355,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 +22395,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 +22423,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 +22433,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 +22452,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 +22479,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 +22489,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 +22503,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 +22521,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 +22530,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 +22550,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 +22559,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 +22576,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 +22600,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 +22619,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 +22662,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 +22682,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 +22697,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 +22711,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 +22730,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 +22803,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 +22876,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 +22890,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 +22898,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 +22990,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 +23121,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 +23139,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 +23157,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 +23169,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 +23187,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 +23217,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22843,7 +23264,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22869,7 +23290,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 +23346,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 +23363,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 +23411,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 +23421,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 +23439,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: @@ -23066,9 +23491,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91) { + write("null"); + } 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 +23576,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 +23594,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 +23609,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 +23635,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 +23701,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 +23714,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 +23723,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 +23769,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 +23796,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 +23809,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 +23833,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 +23857,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 +23870,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 +23898,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 +23920,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 +23943,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 +23955,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 +23966,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 +23990,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 +24015,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 +24056,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 +24112,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); @@ -23724,11 +24151,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; var exportFunctionForFile; var generatedNameSet = {}; @@ -23748,7 +24171,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 +24242,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 +24254,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 +24320,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 +24405,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 +24422,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 +24532,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 +24543,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -24133,7 +24559,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 +24669,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -24269,7 +24697,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 +24710,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 +24722,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 +24748,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 +24782,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 +24809,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 +24842,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 +24854,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 +24880,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 +24891,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 +24919,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 +24968,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 +24988,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 +25012,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 +25024,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 +25047,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 +25079,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24663,58 +25091,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 +25156,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 +25169,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); @@ -24757,17 +25187,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } 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; @@ -24782,6 +25217,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -24841,7 +25279,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24855,7 +25293,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24863,22 +25301,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 +25333,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 +25366,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24989,7 +25427,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 +25478,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 +25516,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 +25530,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 +25580,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 +25595,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 +25636,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 +25662,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 +25678,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 +25690,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -25255,16 +25705,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 +25729,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 +25749,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -25319,13 +25769,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 +25826,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 +25850,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 +25882,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 +25904,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 +25925,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 +25937,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 +25951,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 +25986,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 +26027,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 +26052,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 +26072,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 +26087,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 +26118,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 +26142,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 +26158,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 +26189,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 +26212,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25770,13 +26220,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 +26235,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25797,17 +26247,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 +26269,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 +26285,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 +26314,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 +26349,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 +26369,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 +26388,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 +26425,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25966,6 +26433,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25984,44 +26452,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 +26504,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 +26524,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66) { + if (expr.kind !== 67) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -26064,37 +26536,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 +26580,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 +26593,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 +26604,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 +26621,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 +26655,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 +26690,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 +26709,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 +26721,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 +26729,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 +26827,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -26373,7 +26848,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -26394,7 +26869,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -26403,26 +26878,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 +26905,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 +26928,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 +26964,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 +27007,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26576,10 +27055,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 +27124,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 +27158,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 +27215,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 +27231,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 +27286,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 +27312,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26856,10 +27333,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 +27367,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 +27408,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26936,7 +27416,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 +27439,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 +27456,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 +27483,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -27043,7 +27523,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -27081,7 +27561,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 +27573,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -27101,11 +27581,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 +27659,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 +27695,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 +27734,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 +27783,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 +27831,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 +27886,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 +27902,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 +27922,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27511,7 +27999,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27570,7 +28058,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 +28093,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 +28112,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27637,7 +28125,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 +28137,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 +28198,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 +28224,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 +28236,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27782,16 +28282,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 +28332,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 +28358,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27857,10 +28369,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27873,13 +28384,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 +28401,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 +28416,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27929,18 +28439,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 +28468,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27983,17 +28493,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 +28515,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 +28541,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 +28570,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 +28592,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -28089,17 +28601,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 +28624,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -28130,7 +28644,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 +28659,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 +28693,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 +28716,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28211,10 +28725,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 +28740,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 +28761,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 +28775,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -28262,75 +28783,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 +28853,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 +28887,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 +28908,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -28435,6 +28968,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28454,6 +28988,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28462,6 +28997,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 +29017,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28506,9 +29043,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; for (var i = 0; i < text.length; i++) { @@ -28516,7 +29053,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 +29066,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 +29098,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 +29113,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28600,10 +29147,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 +29169,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 +29197,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 +29262,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 +29453,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 +29465,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 +29485,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 +29534,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,16 +29560,273 @@ 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 = {})); /// /// +/// var ts; (function (ts) { ts.programTime = 0; 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 +29843,172 @@ 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) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function useBaseUrl(moduleName) { + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(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 }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -29072,7 +30071,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 +30108,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 +30119,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 +30174,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 +30252,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 +30333,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 +30408,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 +30428,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 +30439,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 +30459,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 +30472,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 +30547,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 +30576,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 +30611,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 +30623,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 +30689,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 +30820,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 +30871,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 +30891,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 +30926,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 +30965,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 +30990,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 +31080,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 +31092,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 +31131,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 +31217,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 +31231,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 +31248,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 +31259,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 +31323,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 +31341,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 +31369,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 +31417,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 +31438,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 +31493,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135: + case 136: if (ts.isBindingPattern(node.name)) { break; } @@ -30399,34 +31501,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 +31547,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 +31583,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 +31615,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 +31636,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 +31657,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 +32160,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 +32196,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 +32227,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 +32261,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23) { + if (child.kind !== 24) { argumentIndex++; } } @@ -31167,8 +32269,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 +32286,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 +32307,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 +32316,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 +32366,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 +32380,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 +32393,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 +32416,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 +32496,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 +32604,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 +32633,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 +32739,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 +32754,67 @@ 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 getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100: + case 106: + case 72: + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; function nodeHasTokens(n) { return n.getWidth() !== 0; } @@ -31677,32 +32839,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 +32874,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 +32902,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 +33037,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 +33082,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 +33165,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 +33209,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 +33219,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 +33340,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 +33484,90 @@ 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.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -32415,6 +33593,11 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, @@ -32427,6 +33610,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -32436,32 +33620,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 +33662,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 +33694,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 +33735,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 +33837,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 +33911,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 +34088,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 +34130,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 +34216,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 +34276,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 +34328,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 +34463,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 +34498,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 +34517,8 @@ var ts; return { getIndentationForComment: function (kind) { switch (kind) { - case 15: - case 19: + case 16: + case 20: return indentation + delta; } return indentation; @@ -33325,15 +34530,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 +34618,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 +34908,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 +35020,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 +35128,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 +35139,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 +35152,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 +35164,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 +35191,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 +35217,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 +35239,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 +35257,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 +35297,41 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211: case 212: + case 213: + case 215: case 214: - case 161: - case 189: - case 216: 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 231: + case 140: + case 145: + case 146: + case 136: + case 150: + case 151: + case 156: case 158: + case 168: + case 176: return true; } return false; @@ -34123,22 +35341,20 @@ 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 172: case 142: case 143: - return child !== 189; + case 144: + return child !== 190; default: return false; } @@ -34189,6 +35405,45 @@ var ts; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); var scanner = ts.createScanner(2, true); var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -34238,7 +35493,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 +35512,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 +35554,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 +35609,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 +35617,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 +35859,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 +35933,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 +35945,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 +35955,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 +35974,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 +36171,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 +36283,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 +36388,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 +36474,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 +36490,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -35225,66 +36509,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 +36587,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 +36622,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 +36635,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 +36656,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 +36735,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 +36750,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 +36768,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 +36867,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 +36981,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 +37026,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 +37047,7 @@ var ts; return true; } break; - case 135: + case 136: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -35753,17 +37063,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 +37099,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: } } } @@ -35845,6 +37155,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -35852,8 +37163,33 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { + isJsDocTagName = true; + } + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267: + case 265: + case 266: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -35873,13 +37209,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 +37223,7 @@ var ts; return undefined; } } - else if (kind === 24 && sourceFile.languageVariant === 1) { + else if (kind === 25 && sourceFile.languageVariant === 1) { isRightOfOpenTag = true; location = contextToken; } @@ -35916,11 +37252,11 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; 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 +37302,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 +37344,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 +37390,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 +37400,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9; + || contextToken.kind === 10; } } return false; @@ -36073,15 +37409,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 +37440,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 +37461,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 +37475,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 +37488,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 +37521,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 +37538,67 @@ 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 === 184 || + containingNodeKind === 213 || + containingNodeKind === 160 || + containingNodeKind === 214; 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 === 184 || + containingNodeKind === 213 || + containingNodeKind === 214 || + 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 +37616,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 +37644,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 +37670,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235) { + if (attr.kind === 236) { seenNames[attr.name.text] = true; } } @@ -36327,8 +37683,11 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -36339,7 +37698,7 @@ var ts; } entries = getCompletionEntriesFromSymbols(symbols); } - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -36368,6 +37727,16 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } function createCompletionEntry(symbol, location) { var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); if (!displayName) { @@ -36434,7 +37803,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 +37899,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 +37918,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 +37933,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 +37948,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 +37966,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 +37989,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,74 +38001,85 @@ 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); + writeTypeParametersOfSymbol(symbol, sourceFile); 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 signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145) { - displayParts.push(ts.keywordPart(89)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146) { + displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); + } + else { + var declaration = ts.getDeclarationOfKind(symbol, 135).parent; + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } } 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 +38087,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 +38122,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 +38180,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 +38190,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 +38220,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,11 +38273,15 @@ 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); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; @@ -36912,8 +38296,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 +38348,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 +38423,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 +38474,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 +38556,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 +38580,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 +38599,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 +38615,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 +38640,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 +38668,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 +38677,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 +38706,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 +38738,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 +38753,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 +38773,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 +38796,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 +38810,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 +38827,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 +38948,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 +38967,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 +39021,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 +39034,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 +39061,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 +39120,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 +39147,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 +39193,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 +39208,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 +39227,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 +39242,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 +39293,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 +39351,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 +39453,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 +39464,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 +39505,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 +39541,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 +39558,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 +39567,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 +39641,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 +39660,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 +39687,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 +39738,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 +39747,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 +39834,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 +39871,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 +39953,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 +40077,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 +40119,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 +40217,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 +40295,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -38910,13 +40315,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 +40334,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 +40371,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 +40379,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 +40441,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(11); + templateStack.push(12); break; } scanner.setText(text); @@ -39048,55 +40453,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 +40516,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 +40539,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 +40550,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 +40574,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 +40617,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 +40638,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 +40681,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 +40771,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 +40785,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 +40806,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 +40889,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 +41010,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 +41022,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 +41041,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 +41120,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 +41154,7 @@ var ts; configFileName: project.projectFilename }; if (needFileNameList) { - projectInfo.fileNameList = project.getFileNameList(); + projectInfo.fileNames = project.getFileNames(); } return projectInfo; }; @@ -40116,6 +41567,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 +41728,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 +41786,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 +41814,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 +41836,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 +41949,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 +41994,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 +42063,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 +42137,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 +42267,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 +42374,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 +42472,105 @@ 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 (info.isOpen) { + 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 +42615,7 @@ var ts; InsertSpaceAfterKeywordsInControlFlowStatements: true, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false }; @@ -42081,9 +43725,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 +43831,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 +43942,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 +43971,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 +44079,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 +44122,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 +44203,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 +44333,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 ee69b9ca909..f94d24269f1 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 */ @@ -1019,11 +1025,6 @@ declare module "typescript" { emitSkipped: boolean; diagnostics: Diagnostic[]; } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; @@ -1031,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; @@ -1054,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; @@ -1198,7 +1201,7 @@ declare module "typescript" { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1218,8 +1221,6 @@ declare module "typescript" { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1292,6 +1293,10 @@ declare module "typescript" { Error = 1, Message = 2, } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1299,6 +1304,7 @@ declare module "typescript" { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -1315,6 +1321,7 @@ declare module "typescript" { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1330,6 +1337,7 @@ declare module "typescript" { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1367,14 +1375,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; @@ -1448,8 +1467,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; @@ -1489,13 +1511,17 @@ 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 nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule; + function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule; + function classicNameResolver(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; @@ -1559,6 +1585,7 @@ declare module "typescript" { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1600,6 +1627,7 @@ declare module "typescript" { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1620,6 +1648,7 @@ declare module "typescript" { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1660,6 +1689,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; @@ -1696,6 +1726,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; @@ -1716,6 +1751,7 @@ declare module "typescript" { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1743,6 +1779,7 @@ declare module "typescript" { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1985,6 +2022,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; @@ -2071,10 +2109,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..c1105bb262a 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) { @@ -635,6 +644,11 @@ var ts; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -822,6 +836,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +858,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1008,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 +1318,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 +1495,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 +1724,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 +1759,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 +1800,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 +1824,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1860,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 +2127,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 +2167,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 +2298,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_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other 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 +2379,12 @@ 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}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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,11 +2435,13 @@ 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." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2459,7 +2482,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 +2491,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 +2754,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 +2840,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 +2901,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 +2963,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 +3059,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 +3085,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 +3111,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 +3182,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 +3264,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 +3272,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 +3341,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 +3456,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 +3491,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 +3536,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 +3641,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 +3653,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 +3693,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 +3705,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 +3728,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 +3748,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 +3814,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 +3879,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3887,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 +3904,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 +3920,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 +3961,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 +4008,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 +4036,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4114,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 +4125,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 +4211,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 +4292,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 +4359,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 +4420,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 +4443,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 +4453,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 +4496,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 +4508,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 +4530,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 +4554,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 +4590,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 +4598,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 +4646,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 +4690,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 +4723,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 +4827,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,12 +4852,16 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 @@ -4846,7 +4928,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 +4994,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 +5049,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 +5144,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 +5161,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 +5182,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 +5214,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 +5223,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 +5232,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 +5265,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 +5284,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 +5306,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 +5328,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 +5370,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 +5415,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 +5441,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 +5460,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 +5479,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 +5494,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 +5570,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 +5585,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 +5598,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 +5626,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 +5641,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 +5654,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 +5675,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 +5688,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 +5697,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 +5745,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 +5760,94 @@ 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 */: + case 238 /* JsxExpression */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5865,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 +5874,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 +5895,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 +5909,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 +5925,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 +5963,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 +5977,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 +6004,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 +6039,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 +6066,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 +6081,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 +6100,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 +6140,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 +6228,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 +6248,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 +6258,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 +6283,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 +6305,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 +6571,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 +6583,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 +6600,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 +6612,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 +6623,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 +6728,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 +6759,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 +6776,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 +6806,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 +6822,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 +6833,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 +7150,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 +7168,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 +7213,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 +7235,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 +7263,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 +7554,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 +7590,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 +7741,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 +7784,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 +7938,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 +7972,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 +8039,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 +8102,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 +8121,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 +8180,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 +8205,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 +8215,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 +8242,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 +8271,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 +8281,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 +8294,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 +8319,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 +8373,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 +8383,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 +8397,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 +8537,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 +8559,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 +8569,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 +8641,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 +8696,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 +8708,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 +8757,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 +8791,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 +8842,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 +8851,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 +8897,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 +8919,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 +8937,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 +8954,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 +8982,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 +8990,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 +9005,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 +9013,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 +9044,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 +9063,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 +9088,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 +9110,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 +9132,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 +9184,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 +9203,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 +9252,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 +9274,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 +9302,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 +9332,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 +9349,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 +9390,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 +9419,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 +9439,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 +9448,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 +9457,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 +9465,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9499,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 +9519,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 +9548,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 +9567,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 +9590,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 +9600,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 +9611,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 +9624,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 +9657,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 +9675,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 +9683,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 +9693,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 +9718,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 +9731,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 +9744,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 +9773,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 +9781,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 +9800,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 +9812,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 +9836,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 +9883,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 +9931,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 +9941,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 +9969,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 +10009,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 +10069,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 +10118,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 +10131,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 +10162,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 +10277,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 +10286,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 +10304,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 +10326,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 +10362,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 +10386,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 +10450,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 +10495,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 +10506,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 +10517,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 +10558,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 +10643,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 +10651,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 +10660,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 +10707,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 +10749,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 +10771,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 +10808,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 +10850,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 +10900,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 +10909,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 +10980,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 +11018,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 +11113,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 +11125,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 +11166,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 +11193,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 +11206,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 +11230,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 +11247,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 +11257,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 +11290,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 +11331,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 +11345,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 +11357,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11192,16 +11366,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 +11384,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 +11420,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 +11430,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 +11471,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 +11492,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 +11503,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 +11593,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 +11602,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 +11627,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 +11635,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 +11650,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 +11671,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 +11682,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 +11710,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 +11783,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 +11831,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 +11861,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 +11887,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 +11914,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 +12008,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 +12019,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 +12062,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 +12073,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 +12097,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 +12195,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 +12206,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 +12232,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); @@ -12098,7 +12272,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -12110,7 +12283,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 +12293,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 +12326,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 +12337,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 +12358,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 +12378,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 +12434,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 +12447,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12479,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 +12573,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 +12597,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 +12890,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 +12920,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 +12929,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 +12986,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +13008,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13021,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 +13174,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 +13203,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 +13234,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 +13254,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 +13268,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 +13291,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 +13304,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 +13320,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 +13330,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 +13355,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 +13364,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 +13399,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 +13431,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 +13467,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 +13480,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 +13587,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 +13642,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 +13659,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 +13668,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 +13691,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 +13725,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 +13733,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 +13852,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 +13922,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 +13973,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 +14010,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 +14026,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 +14083,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 +14120,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 +14135,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 +14180,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 +14197,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 +14230,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14286,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 +14314,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 +14340,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 +14376,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 +14384,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 +14416,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14440,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 +14450,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 +14468,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,32 +14549,32 @@ 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) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -14395,7 +14583,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 +14591,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 +14673,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 +14687,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 +14741,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 +14820,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 +14851,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 +14951,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 +14968,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 +14995,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 +15012,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 +15032,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 +15071,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 +15094,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 +15116,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 +15138,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 +15170,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 +15183,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 +15216,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 +15316,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 +15328,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 +15337,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 +15381,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 +15449,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 +15458,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 +15468,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 +15504,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 +15540,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 +15707,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 +15921,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 +15938,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 +16023,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 +16053,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 +16109,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 +16133,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 +16156,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 +16168,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 +16187,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 +16216,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16276,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 +16290,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 +16319,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 +16344,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 +16379,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 +16417,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 +16472,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 +16504,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 +16540,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 +16589,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 +16617,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 +16704,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 +16731,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 +16763,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 +16800,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 +16899,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 +16908,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16659,6 +16970,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -16671,6 +16991,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -16689,7 +17010,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 +17021,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 +17065,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 +17085,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 +17130,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 +17148,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 +17352,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 +17558,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 +17596,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 +17713,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 +17726,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 +17750,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 +17837,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 +17870,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 +17947,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 +17991,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 +18046,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 +18060,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 +18088,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 +18125,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 +18151,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 +18191,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 +18365,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 +18414,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 +18433,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 +18498,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 +18545,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 +18569,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 +18583,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 +18599,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 +18646,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 +18682,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 +18720,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 +18751,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 +18760,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 +18785,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 +18796,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 +18839,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 +18973,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 +19006,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 +19017,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 +19040,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 +19048,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 +19150,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 +19161,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 +19171,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 +19192,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 +19240,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 +19254,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 +19268,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 +19294,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 +19336,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 +19348,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 +19363,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 +19372,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 +19383,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 +19423,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 +19442,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 +19473,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 +19484,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 +19517,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 +19565,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 +19582,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 +19670,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 +19680,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 +19705,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 +19726,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 +19744,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 +19780,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 +19862,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 +19874,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 +19908,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 +19924,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 +19935,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 +19968,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 +20018,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 +20034,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 +20053,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 +20081,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 +20111,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 +20136,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 +20163,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 +20196,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 +20210,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 +20232,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 +20244,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 +20263,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 +20319,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 +20355,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 +20414,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 +20446,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 +20480,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 +20523,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 +20570,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 +20624,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 +20668,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 +20683,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 +20693,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 +20706,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 +20809,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 +20839,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 +20864,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 +20872,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 +20884,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 +20919,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 +20993,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 +21052,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 +21098,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 +21125,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 +21147,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 +21166,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 +21230,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 +21349,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 +21364,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 +21382,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 +21398,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 +21457,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 +21503,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 +21528,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 +21587,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 +21663,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 +21677,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 +21689,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 +21714,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 +21744,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 +21757,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 +21772,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 +21831,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 +21866,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 +21913,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 +21938,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 +21976,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 +21988,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 +22034,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 +22045,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 +22075,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 +22087,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 +22103,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 +22203,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 +22220,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 +22238,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 +22271,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 +22281,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 +22317,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 +22348,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 +22368,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 +22376,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22425,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 +22507,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 +22515,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 +22611,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 +22631,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 +22717,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 +22753,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 +22764,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 +22848,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 +22865,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 +22990,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 +23157,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,11 +23185,18 @@ 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); - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -22714,19 +23206,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 +23247,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 +23291,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 +23340,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 +23363,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 +23377,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 +23393,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 +23416,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 +23430,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 +23470,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 +23505,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 +23542,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 +23553,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 +23570,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 +23582,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 +23611,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 +23649,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 +23674,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 +23689,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 +23710,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 +23724,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 +23753,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 +23896,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 +23920,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 +23963,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 +23986,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 +24025,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 +24037,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 +24058,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 +24088,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 +24163,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 +24334,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 +24382,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 +24452,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 +24473,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 +24506,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 +24522,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 +24573,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 +24620,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 +24650,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24694,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 +24717,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 +24741,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 +24750,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 +24774,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 +24794,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 +24838,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 +24865,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 +24902,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 +24922,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 +24937,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 +24952,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 +24961,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 +24980,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 +25022,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 +25148,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 +25322,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 +25345,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 +25372,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 +25415,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 +25463,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 +25477,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 +25491,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 +25513,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 +25537,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 +25597,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 +25619,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 +25711,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 +25730,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 +25745,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 +25764,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 +25792,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 +25841,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 +25856,20 @@ 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); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25891,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 +25926,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 +25935,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 +25983,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +26004,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 +26016,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 +26030,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 +26076,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 +26086,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 +26132,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 +26156,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 +26169,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 +26188,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 +26201,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 +26248,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 +26263,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 +26281,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 +26296,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 +26347,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 +26365,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 +26400,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 +26433,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 +26460,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 +26473,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 +26489,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 +26507,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 +26545,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 +26560,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 +26606,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 +26618,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 +26627,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 +26667,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 +26695,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 +26705,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 +26729,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 +26756,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 +26784,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 +26802,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 +26812,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 +26839,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 +26848,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 +26865,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 +26889,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 +26918,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 +26961,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 +26981,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 +27006,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 +27020,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 +27046,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 +27067,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 +27128,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 +27204,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 +27225,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 +27235,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 +27323,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 +27332,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 +27383,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 +27470,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 +27490,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 +27509,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 +27522,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 +27540,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 +27572,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 +27621,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 +27649,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 +27707,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 +27724,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 +27772,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 +27783,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 +27802,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: @@ -27325,10 +27854,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + write("null"); + } 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 +27900,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 +27921,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 +27944,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 +27954,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 +27966,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 +27982,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 +28014,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 +28035,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28084,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 +28097,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 +28106,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 +28156,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 +28184,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 +28198,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 +28224,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 +28251,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 +28265,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 +28296,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 +28318,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 +28343,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 +28356,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 +28368,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 +28392,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 +28401,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 +28411,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 +28424,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 +28440,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 +28482,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 +28556,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 @@ -28068,11 +28598,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -28100,7 +28626,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 +28661,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28721,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 +28733,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 +28811,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 +28917,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 +28935,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 +29007,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 +29043,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 +29060,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 +29071,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29088,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 +29198,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 +29218,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 +29231,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 +29244,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 +29258,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 +29268,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 +29295,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 +29333,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 +29371,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 +29413,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 +29438,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 +29466,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 +29480,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 +29514,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 +29567,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 +29589,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 +29613,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 +29625,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 +29648,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 +29660,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 +29696,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29708,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 +29773,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 +29788,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("."); @@ -29268,17 +29808,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } 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; @@ -29293,6 +29838,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -29322,13 +29870,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 +29900,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 +29914,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +29922,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 +29957,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 +29990,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 +29999,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 +30019,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 +30029,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30060,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 +30112,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 +30152,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 +30168,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 +30190,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 +30202,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 +30228,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 +30263,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 +30308,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 +30339,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 +30347,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 +30367,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30382,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 +30406,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 +30428,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 +30442,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 +30451,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 +30499,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 +30526,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 +30542,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 +30560,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 +30608,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 +30633,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 +30646,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 +30664,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 +30676,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 +30691,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 +30730,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 +30771,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 +30796,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 +30818,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 +30837,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 +30868,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 +30892,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 +30908,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 +30939,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 +30950,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 +30975,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +30984,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 +30993,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 +31001,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 +31022,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 +31046,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 +31062,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 +31091,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 +31126,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 +31146,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 +31165,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 +31207,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31215,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31234,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 +31271,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 +31290,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 +31310,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 +31325,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 +31350,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 +31373,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 +31388,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 +31399,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 +31416,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 +31454,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 +31478,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 +31498,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 +31517,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 +31529,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 +31537,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 +31626,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 +31646,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31668,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31689,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,27 +31698,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 +31727,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 +31765,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 +31787,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 +31802,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 +31923,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +31978,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 +32001,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +32012,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +32029,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 +32039,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 +32085,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 +32145,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 +32161,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 +32216,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 +32242,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32267,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 +32310,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 +32347,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 +32384,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 +32463,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 +32492,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 +32515,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 +32548,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 +32583,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 +32607,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 +32625,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32654,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 +32703,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 +32741,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 +32756,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 +32771,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 +32794,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 +32813,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 +32826,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 +32836,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; @@ -32235,22 +32853,22 @@ var ts; // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // 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 +32879,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 +32928,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"); @@ -32360,11 +32987,11 @@ var ts; // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // 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 +33007,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 +33028,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 +33109,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 +33170,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 +33206,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 +33225,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 +33239,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 +33251,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 +33304,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 +33317,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 +33343,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 +33362,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 +33413,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 +33468,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 +33495,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33507,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33522,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 +33539,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 +33554,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33577,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 +33587,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 +33614,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33640,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 +33663,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 +33697,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 +33729,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 +33754,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33763,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 +33777,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 +33788,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33817,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 +33833,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 +33867,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 +33890,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33899,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 +33914,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 +33940,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 +33990,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 +34081,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 +34132,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 +34154,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34221,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 +34260,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 +34271,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,9 +34300,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the @@ -33631,7 +34313,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 +34326,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 { @@ -33660,19 +34353,19 @@ var ts; } case 1 /* Preserve */: default: - return ts.getTextOfNode(node, true); + return ts.getTextOfNode(node, /*includeTrivia*/ true); } } 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, /*includeTrivia*/ true)); break; } } @@ -33681,9 +34374,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 +34409,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 +34434,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 +34464,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 +34544,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 +34725,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 +34744,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 +34759,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 +34776,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 +34807,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 +34837,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 +34849,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,9 +34875,265 @@ 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 = {})); /// /// +/// var ts; (function (ts) { /* @internal */ ts.programTime = 0; @@ -34149,7 +35141,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 +35159,180 @@ 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) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function useBaseUrl(moduleName) { + // path is not rooted + // module name does not start with './' or '../' + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(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 }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35398,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 +35435,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 +35446,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 +35509,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 +35587,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 +35600,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 +35611,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 +35702,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 +35785,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 +35794,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 +35820,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 +35841,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 +35854,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 +35934,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 +35963,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 +36003,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 +36020,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 */) { @@ -34789,6 +36077,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -34879,6 +36172,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 @@ -34977,20 +36277,40 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -35088,7 +36408,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 +36492,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 +36573,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 +36590,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 +36606,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 +36652,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 +36745,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 +36759,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 +36780,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 +36793,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 +36869,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 +36890,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 +36916,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 +36925,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 +36987,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 +37008,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 +37073,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +37081,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 +37129,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 +37165,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 +37199,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 +37220,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 +37244,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 +37253,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 +37362,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 +37383,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 +37395,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 +37421,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 +37445,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 +37491,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 +37757,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 +38054,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 +38095,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 +38111,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 +38148,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 +38196,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38215,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 +38246,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 +38268,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 +38284,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 +38344,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 +38353,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 +38367,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 +38380,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 +38404,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 +38493,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 +38535,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 +38610,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 +38648,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 +38673,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 +38758,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 +38772,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 +38782,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 +38802,86 @@ 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; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; 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 +38908,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 +38943,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 +38973,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 +39108,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 +39160,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 +39188,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 +39258,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 +39312,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 +39322,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 +39451,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 +39643,128 @@ 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 */)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Type alias declaration + this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // union type + this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38365,6 +39791,11 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -38378,6 +39809,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39820,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 +39830,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 +39879,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 +39918,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 +39962,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 +40071,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 +40146,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 +40341,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 +40383,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 +40471,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 +40539,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 +40607,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 +40790,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 +40828,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 +40852,8 @@ var ts; // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: return indentation + delta; } return indentation; @@ -39413,15 +40867,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 +40922,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 +40975,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 +41010,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 +41068,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 +41137,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 +41146,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 +41186,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 +41298,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 +41417,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 +41467,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 +41546,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 +41557,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 +41579,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 +41591,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 +41618,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 +41646,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 +41668,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 +41688,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 +41736,41 @@ 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 214 /* TypeAliasDeclaration */: + 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 */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 136 /* Parameter */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 156 /* UnionType */: + case 158 /* ParenthesizedType */: + case 168 /* TaggedTemplateExpression */: + case 176 /* AwaitExpression */: return true; } return false; @@ -40313,22 +41780,20 @@ 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 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,8 +41845,47 @@ 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 = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -40431,7 +41935,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 +41954,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 +41996,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 +42050,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 +42067,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 +42088,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 +42190,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 +42240,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 +42293,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 +42343,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 +42419,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 +42431,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 +42441,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 +42463,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 +42528,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 +42732,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 +42758,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 +42836,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 +42861,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 +42944,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 +42990,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 +42998,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 +43036,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 +43056,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 +43095,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 +43111,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41603,31 +43140,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 +43183,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +43192,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 +43210,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 +43229,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 +43249,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 +43268,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 +43282,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 +43296,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 +43307,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 +43408,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 +43423,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 +43441,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 +43543,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 +43596,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 +43616,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 +43627,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 +43694,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 +43718,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 +43763,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 +43784,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 +43800,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 +43836,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 */: } } } @@ -42343,6 +43909,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -42351,8 +43918,40 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267 /* JSDocTypeTag */: + case 265 /* JSDocParameterTag */: + case 266 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -42380,13 +43979,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 +43995,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; } @@ -42428,12 +44027,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // 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 +44061,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 +44088,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 +44109,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 +44162,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 +44209,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 +44223,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +44239,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 +44292,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 +44317,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 +44335,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 +44348,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 +44384,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 +44404,67 @@ 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 === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */ || + containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + 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 === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 214 /* TypeAliasDeclaration */ || 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 +44483,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 +44528,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 +44538,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 +44565,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; } } @@ -42956,8 +44578,12 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -42969,7 +44595,7 @@ var ts; entries = getCompletionEntriesFromSymbols(symbols); } // Add keywords if this is not a member completion list - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -42983,7 +44609,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, @@ -42998,18 +44624,28 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } 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 +44685,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 +44717,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 +44781,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 +44819,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 +44828,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 +44841,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 +44858,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 +44874,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 +44893,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 +44919,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 +44927,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 +44935,49 @@ 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); + writeTypeParametersOfSymbol(symbol, sourceFile); 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,26 +44986,39 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } 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 +45026,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 +45062,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 +45100,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 +45121,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 +45131,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 +45162,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 +45210,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 +45219,24 @@ 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); + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } 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 +45244,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 +45274,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 +45305,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 +45348,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 +45362,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 +45388,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 +45441,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 +45527,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 +45558,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 +45579,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 +45595,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 +45623,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 +45652,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 +45662,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 +45693,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 +45725,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 +45740,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 +45761,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 +45784,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 +45799,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 +45816,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 +45830,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 +45868,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 +45935,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 +45950,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 +45958,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 +45976,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 +46039,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 +46066,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 +46099,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 +46127,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 +46170,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 +46203,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 +46256,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 +46291,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 +46306,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 +46339,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 +46365,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 +46444,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 +46480,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 +46495,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 +46571,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 +46583,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 +46625,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 +46661,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 +46679,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 +46688,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 +46771,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 +46793,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 +46829,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 +46893,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 +46903,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 +46964,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 +46996,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 +47040,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 +47048,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 +47092,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 +47128,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 +47137,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 +47146,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 +47177,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 +47271,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 +47313,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 +47403,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 +47425,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 +47470,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 +47504,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 +47584,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47605,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 +47628,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 +47675,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 +47697,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 +47706,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 +47777,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47796,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 +47887,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 +47913,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 +47924,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 +47935,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 +47954,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 +47997,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 +48018,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 +48067,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 +48137,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 +48302,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 +48361,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 +48384,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 +48403,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 +48423,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 +48437,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 +48469,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 +48479,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 +48500,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 +48581,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 +48700,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 +48826,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 +48859,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 +48995,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 +49046,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 +49133,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 +49270,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 7b4eaea9e16..812305c8a68 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 */ @@ -1019,11 +1025,6 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; @@ -1031,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; @@ -1054,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; @@ -1198,7 +1201,7 @@ declare namespace ts { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1218,8 +1221,6 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1292,6 +1293,10 @@ declare namespace ts { Error = 1, Message = 2, } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1299,6 +1304,7 @@ declare namespace ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -1315,6 +1321,7 @@ declare namespace ts { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1330,6 +1337,7 @@ declare namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1367,14 +1375,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; @@ -1448,9 +1467,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; @@ -1490,13 +1511,17 @@ 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 nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule; + function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule; + function classicNameResolver(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; @@ -1560,6 +1585,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1601,6 +1627,7 @@ declare namespace ts { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1621,6 +1648,7 @@ declare namespace ts { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1661,6 +1689,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; @@ -1697,6 +1726,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; @@ -1717,6 +1751,7 @@ declare namespace ts { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1744,6 +1779,7 @@ declare namespace ts { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1986,6 +2022,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; @@ -2072,10 +2109,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..c1105bb262a 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) { @@ -635,6 +644,11 @@ var ts; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -822,6 +836,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +858,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1008,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 +1318,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 +1495,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 +1724,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 +1759,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 +1800,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 +1824,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1860,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 +2127,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 +2167,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 +2298,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_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other 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 +2379,12 @@ 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}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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,11 +2435,13 @@ 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." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2459,7 +2482,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 +2491,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 +2754,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 +2840,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 +2901,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 +2963,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 +3059,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 +3085,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 +3111,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 +3182,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 +3264,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 +3272,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 +3341,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 +3456,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 +3491,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 +3536,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 +3641,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 +3653,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 +3693,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 +3705,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 +3728,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 +3748,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 +3814,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 +3879,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3887,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 +3904,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 +3920,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 +3961,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 +4008,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 +4036,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4114,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 +4125,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 +4211,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 +4292,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 +4359,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 +4420,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 +4443,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 +4453,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 +4496,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 +4508,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 +4530,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 +4554,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 +4590,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 +4598,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 +4646,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 +4690,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 +4723,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 +4827,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,12 +4852,16 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 @@ -4846,7 +4928,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 +4994,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 +5049,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 +5144,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 +5161,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 +5182,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 +5214,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 +5223,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 +5232,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 +5265,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 +5284,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 +5306,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 +5328,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 +5370,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 +5415,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 +5441,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 +5460,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 +5479,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 +5494,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 +5570,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 +5585,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 +5598,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 +5626,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 +5641,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 +5654,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 +5675,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 +5688,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 +5697,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 +5745,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 +5760,94 @@ 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 */: + case 238 /* JsxExpression */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5865,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 +5874,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 +5895,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 +5909,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 +5925,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 +5963,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 +5977,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 +6004,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 +6039,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 +6066,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 +6081,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 +6100,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 +6140,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 +6228,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 +6248,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 +6258,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 +6283,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 +6305,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 +6571,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 +6583,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 +6600,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 +6612,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 +6623,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 +6728,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 +6759,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 +6776,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 +6806,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 +6822,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 +6833,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 +7150,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 +7168,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 +7213,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 +7235,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 +7263,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 +7554,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 +7590,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 +7741,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 +7784,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 +7938,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 +7972,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 +8039,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 +8102,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 +8121,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 +8180,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 +8205,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 +8215,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 +8242,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 +8271,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 +8281,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 +8294,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 +8319,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 +8373,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 +8383,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 +8397,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 +8537,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 +8559,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 +8569,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 +8641,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 +8696,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 +8708,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 +8757,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 +8791,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 +8842,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 +8851,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 +8897,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 +8919,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 +8937,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 +8954,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 +8982,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 +8990,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 +9005,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 +9013,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 +9044,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 +9063,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 +9088,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 +9110,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 +9132,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 +9184,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 +9203,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 +9252,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 +9274,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 +9302,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 +9332,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 +9349,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 +9390,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 +9419,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 +9439,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 +9448,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 +9457,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 +9465,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9499,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 +9519,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 +9548,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 +9567,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 +9590,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 +9600,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 +9611,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 +9624,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 +9657,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 +9675,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 +9683,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 +9693,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 +9718,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 +9731,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 +9744,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 +9773,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 +9781,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 +9800,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 +9812,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 +9836,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 +9883,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 +9931,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 +9941,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 +9969,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 +10009,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 +10069,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 +10118,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 +10131,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 +10162,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 +10277,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 +10286,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 +10304,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 +10326,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 +10362,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 +10386,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 +10450,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 +10495,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 +10506,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 +10517,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 +10558,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 +10643,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 +10651,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 +10660,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 +10707,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 +10749,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 +10771,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 +10808,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 +10850,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 +10900,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 +10909,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 +10980,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 +11018,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 +11113,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 +11125,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 +11166,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 +11193,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 +11206,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 +11230,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 +11247,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 +11257,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 +11290,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 +11331,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 +11345,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 +11357,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11192,16 +11366,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 +11384,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 +11420,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 +11430,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 +11471,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 +11492,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 +11503,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 +11593,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 +11602,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 +11627,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 +11635,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 +11650,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 +11671,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 +11682,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 +11710,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 +11783,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 +11831,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 +11861,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 +11887,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 +11914,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 +12008,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 +12019,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 +12062,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 +12073,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 +12097,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 +12195,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 +12206,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 +12232,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); @@ -12098,7 +12272,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -12110,7 +12283,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 +12293,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 +12326,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 +12337,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 +12358,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 +12378,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 +12434,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 +12447,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12479,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 +12573,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 +12597,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 +12890,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 +12920,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 +12929,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 +12986,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +13008,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13021,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 +13174,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 +13203,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 +13234,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 +13254,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 +13268,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 +13291,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 +13304,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 +13320,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 +13330,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 +13355,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 +13364,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 +13399,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 +13431,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 +13467,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 +13480,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 +13587,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 +13642,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 +13659,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 +13668,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 +13691,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 +13725,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 +13733,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 +13852,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 +13922,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 +13973,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 +14010,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 +14026,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 +14083,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 +14120,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 +14135,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 +14180,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 +14197,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 +14230,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14286,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 +14314,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 +14340,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 +14376,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 +14384,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 +14416,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14440,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 +14450,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 +14468,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,32 +14549,32 @@ 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) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -14395,7 +14583,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 +14591,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 +14673,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 +14687,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 +14741,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 +14820,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 +14851,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 +14951,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 +14968,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 +14995,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 +15012,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 +15032,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 +15071,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 +15094,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 +15116,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 +15138,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 +15170,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 +15183,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 +15216,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 +15316,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 +15328,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 +15337,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 +15381,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 +15449,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 +15458,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 +15468,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 +15504,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 +15540,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 +15707,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 +15921,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 +15938,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 +16023,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 +16053,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 +16109,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 +16133,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 +16156,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 +16168,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 +16187,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 +16216,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16276,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 +16290,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 +16319,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 +16344,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 +16379,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 +16417,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 +16472,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 +16504,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 +16540,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 +16589,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 +16617,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 +16704,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 +16731,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 +16763,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 +16800,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 +16899,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 +16908,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16659,6 +16970,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -16671,6 +16991,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -16689,7 +17010,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 +17021,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 +17065,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 +17085,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 +17130,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 +17148,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 +17352,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 +17558,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 +17596,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 +17713,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 +17726,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 +17750,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 +17837,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 +17870,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 +17947,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 +17991,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 +18046,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 +18060,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 +18088,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 +18125,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 +18151,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 +18191,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 +18365,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 +18414,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 +18433,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 +18498,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 +18545,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 +18569,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 +18583,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 +18599,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 +18646,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 +18682,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 +18720,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 +18751,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 +18760,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 +18785,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 +18796,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 +18839,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 +18973,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 +19006,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 +19017,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 +19040,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 +19048,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 +19150,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 +19161,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 +19171,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 +19192,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 +19240,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 +19254,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 +19268,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 +19294,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 +19336,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 +19348,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 +19363,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 +19372,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 +19383,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 +19423,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 +19442,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 +19473,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 +19484,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 +19517,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 +19565,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 +19582,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 +19670,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 +19680,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 +19705,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 +19726,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 +19744,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 +19780,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 +19862,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 +19874,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 +19908,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 +19924,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 +19935,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 +19968,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 +20018,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 +20034,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 +20053,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 +20081,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 +20111,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 +20136,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 +20163,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 +20196,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 +20210,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 +20232,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 +20244,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 +20263,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 +20319,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 +20355,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 +20414,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 +20446,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 +20480,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 +20523,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 +20570,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 +20624,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 +20668,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 +20683,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 +20693,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 +20706,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 +20809,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 +20839,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 +20864,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 +20872,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 +20884,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 +20919,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 +20993,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 +21052,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 +21098,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 +21125,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 +21147,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 +21166,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 +21230,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 +21349,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 +21364,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 +21382,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 +21398,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 +21457,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 +21503,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 +21528,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 +21587,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 +21663,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 +21677,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 +21689,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 +21714,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 +21744,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 +21757,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 +21772,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 +21831,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 +21866,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 +21913,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 +21938,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 +21976,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 +21988,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 +22034,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 +22045,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 +22075,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 +22087,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 +22103,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 +22203,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 +22220,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 +22238,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 +22271,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 +22281,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 +22317,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 +22348,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 +22368,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 +22376,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22425,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 +22507,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 +22515,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 +22611,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 +22631,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 +22717,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 +22753,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 +22764,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 +22848,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 +22865,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 +22990,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 +23157,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,11 +23185,18 @@ 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); - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -22714,19 +23206,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 +23247,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 +23291,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 +23340,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 +23363,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 +23377,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 +23393,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 +23416,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 +23430,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 +23470,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 +23505,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 +23542,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 +23553,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 +23570,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 +23582,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 +23611,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 +23649,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 +23674,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 +23689,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 +23710,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 +23724,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 +23753,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 +23896,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 +23920,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 +23963,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 +23986,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 +24025,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 +24037,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 +24058,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 +24088,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 +24163,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 +24334,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 +24382,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 +24452,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 +24473,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 +24506,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 +24522,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 +24573,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 +24620,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 +24650,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24694,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 +24717,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 +24741,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 +24750,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 +24774,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 +24794,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 +24838,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 +24865,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 +24902,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 +24922,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 +24937,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 +24952,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 +24961,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 +24980,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 +25022,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 +25148,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 +25322,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 +25345,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 +25372,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 +25415,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 +25463,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 +25477,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 +25491,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 +25513,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 +25537,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 +25597,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 +25619,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 +25711,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 +25730,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 +25745,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 +25764,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 +25792,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 +25841,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 +25856,20 @@ 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); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25891,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 +25926,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 +25935,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 +25983,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +26004,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 +26016,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 +26030,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 +26076,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 +26086,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 +26132,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 +26156,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 +26169,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 +26188,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 +26201,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 +26248,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 +26263,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 +26281,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 +26296,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 +26347,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 +26365,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 +26400,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 +26433,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 +26460,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 +26473,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 +26489,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 +26507,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 +26545,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 +26560,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 +26606,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 +26618,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 +26627,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 +26667,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 +26695,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 +26705,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 +26729,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 +26756,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 +26784,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 +26802,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 +26812,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 +26839,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 +26848,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 +26865,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 +26889,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 +26918,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 +26961,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 +26981,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 +27006,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 +27020,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 +27046,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 +27067,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 +27128,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 +27204,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 +27225,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 +27235,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 +27323,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 +27332,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 +27383,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 +27470,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 +27490,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 +27509,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 +27522,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 +27540,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 +27572,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 +27621,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 +27649,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 +27707,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 +27724,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 +27772,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 +27783,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 +27802,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: @@ -27325,10 +27854,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + write("null"); + } 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 +27900,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 +27921,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 +27944,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 +27954,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 +27966,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 +27982,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 +28014,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 +28035,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28084,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 +28097,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 +28106,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 +28156,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 +28184,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 +28198,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 +28224,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 +28251,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 +28265,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 +28296,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 +28318,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 +28343,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 +28356,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 +28368,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 +28392,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 +28401,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 +28411,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 +28424,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 +28440,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 +28482,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 +28556,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 @@ -28068,11 +28598,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -28100,7 +28626,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 +28661,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28721,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 +28733,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 +28811,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 +28917,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 +28935,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 +29007,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 +29043,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 +29060,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 +29071,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29088,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 +29198,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 +29218,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 +29231,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 +29244,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 +29258,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 +29268,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 +29295,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 +29333,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 +29371,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 +29413,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 +29438,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 +29466,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 +29480,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 +29514,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 +29567,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 +29589,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 +29613,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 +29625,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 +29648,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 +29660,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 +29696,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29708,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 +29773,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 +29788,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("."); @@ -29268,17 +29808,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } 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; @@ -29293,6 +29838,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -29322,13 +29870,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 +29900,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 +29914,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +29922,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 +29957,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 +29990,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 +29999,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 +30019,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 +30029,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30060,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 +30112,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 +30152,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 +30168,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 +30190,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 +30202,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 +30228,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 +30263,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 +30308,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 +30339,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 +30347,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 +30367,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30382,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 +30406,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 +30428,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 +30442,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 +30451,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 +30499,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 +30526,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 +30542,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 +30560,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 +30608,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 +30633,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 +30646,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 +30664,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 +30676,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 +30691,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 +30730,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 +30771,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 +30796,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 +30818,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 +30837,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 +30868,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 +30892,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 +30908,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 +30939,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 +30950,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 +30975,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +30984,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 +30993,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 +31001,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 +31022,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 +31046,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 +31062,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 +31091,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 +31126,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 +31146,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 +31165,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 +31207,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31215,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31234,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 +31271,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 +31290,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 +31310,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 +31325,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 +31350,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 +31373,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 +31388,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 +31399,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 +31416,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 +31454,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 +31478,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 +31498,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 +31517,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 +31529,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 +31537,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 +31626,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 +31646,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31668,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31689,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,27 +31698,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 +31727,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 +31765,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 +31787,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 +31802,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 +31923,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +31978,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 +32001,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +32012,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +32029,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 +32039,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 +32085,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 +32145,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 +32161,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 +32216,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 +32242,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32267,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 +32310,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 +32347,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 +32384,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 +32463,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 +32492,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 +32515,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 +32548,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 +32583,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 +32607,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 +32625,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32654,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 +32703,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 +32741,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 +32756,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 +32771,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 +32794,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 +32813,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 +32826,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 +32836,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; @@ -32235,22 +32853,22 @@ var ts; // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // 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 +32879,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 +32928,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"); @@ -32360,11 +32987,11 @@ var ts; // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // 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 +33007,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 +33028,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 +33109,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 +33170,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 +33206,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 +33225,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 +33239,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 +33251,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 +33304,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 +33317,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 +33343,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 +33362,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 +33413,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 +33468,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 +33495,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33507,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33522,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 +33539,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 +33554,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33577,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 +33587,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 +33614,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33640,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 +33663,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 +33697,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 +33729,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 +33754,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33763,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 +33777,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 +33788,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33817,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 +33833,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 +33867,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 +33890,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33899,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 +33914,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 +33940,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 +33990,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 +34081,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 +34132,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 +34154,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34221,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 +34260,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 +34271,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,9 +34300,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the @@ -33631,7 +34313,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 +34326,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 { @@ -33660,19 +34353,19 @@ var ts; } case 1 /* Preserve */: default: - return ts.getTextOfNode(node, true); + return ts.getTextOfNode(node, /*includeTrivia*/ true); } } 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, /*includeTrivia*/ true)); break; } } @@ -33681,9 +34374,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 +34409,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 +34434,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 +34464,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 +34544,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 +34725,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 +34744,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 +34759,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 +34776,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 +34807,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 +34837,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 +34849,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,9 +34875,265 @@ 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 = {})); /// /// +/// var ts; (function (ts) { /* @internal */ ts.programTime = 0; @@ -34149,7 +35141,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 +35159,180 @@ 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) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function useBaseUrl(moduleName) { + // path is not rooted + // module name does not start with './' or '../' + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(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 }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35398,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 +35435,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 +35446,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 +35509,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 +35587,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 +35600,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 +35611,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 +35702,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 +35785,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 +35794,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 +35820,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 +35841,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 +35854,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 +35934,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 +35963,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 +36003,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 +36020,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 */) { @@ -34789,6 +36077,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -34879,6 +36172,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 @@ -34977,20 +36277,40 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -35088,7 +36408,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 +36492,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 +36573,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 +36590,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 +36606,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 +36652,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 +36745,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 +36759,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 +36780,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 +36793,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 +36869,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 +36890,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 +36916,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 +36925,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 +36987,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 +37008,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 +37073,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +37081,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 +37129,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 +37165,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 +37199,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 +37220,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 +37244,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 +37253,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 +37362,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 +37383,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 +37395,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 +37421,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 +37445,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 +37491,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 +37757,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 +38054,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 +38095,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 +38111,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 +38148,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 +38196,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38215,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 +38246,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 +38268,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 +38284,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 +38344,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 +38353,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 +38367,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 +38380,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 +38404,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 +38493,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 +38535,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 +38610,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 +38648,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 +38673,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 +38758,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 +38772,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 +38782,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 +38802,86 @@ 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; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; 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 +38908,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 +38943,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 +38973,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 +39108,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 +39160,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 +39188,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 +39258,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 +39312,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 +39322,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 +39451,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 +39643,128 @@ 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 */)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Type alias declaration + this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // union type + this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38365,6 +39791,11 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -38378,6 +39809,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39820,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 +39830,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 +39879,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 +39918,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 +39962,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 +40071,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 +40146,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 +40341,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 +40383,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 +40471,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 +40539,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 +40607,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 +40790,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 +40828,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 +40852,8 @@ var ts; // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: return indentation + delta; } return indentation; @@ -39413,15 +40867,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 +40922,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 +40975,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 +41010,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 +41068,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 +41137,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 +41146,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 +41186,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 +41298,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 +41417,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 +41467,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 +41546,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 +41557,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 +41579,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 +41591,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 +41618,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 +41646,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 +41668,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 +41688,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 +41736,41 @@ 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 214 /* TypeAliasDeclaration */: + 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 */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 136 /* Parameter */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 156 /* UnionType */: + case 158 /* ParenthesizedType */: + case 168 /* TaggedTemplateExpression */: + case 176 /* AwaitExpression */: return true; } return false; @@ -40313,22 +41780,20 @@ 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 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,8 +41845,47 @@ 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 = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -40431,7 +41935,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 +41954,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 +41996,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 +42050,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 +42067,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 +42088,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 +42190,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 +42240,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 +42293,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 +42343,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 +42419,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 +42431,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 +42441,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 +42463,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 +42528,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 +42732,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 +42758,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 +42836,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 +42861,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 +42944,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 +42990,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 +42998,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 +43036,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 +43056,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 +43095,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 +43111,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41603,31 +43140,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 +43183,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +43192,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 +43210,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 +43229,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 +43249,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 +43268,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 +43282,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 +43296,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 +43307,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 +43408,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 +43423,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 +43441,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 +43543,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 +43596,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 +43616,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 +43627,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 +43694,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 +43718,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 +43763,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 +43784,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 +43800,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 +43836,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 */: } } } @@ -42343,6 +43909,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -42351,8 +43918,40 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267 /* JSDocTypeTag */: + case 265 /* JSDocParameterTag */: + case 266 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -42380,13 +43979,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 +43995,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; } @@ -42428,12 +44027,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // 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 +44061,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 +44088,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 +44109,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 +44162,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 +44209,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 +44223,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +44239,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 +44292,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 +44317,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 +44335,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 +44348,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 +44384,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 +44404,67 @@ 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 === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */ || + containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + 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 === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 214 /* TypeAliasDeclaration */ || 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 +44483,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 +44528,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 +44538,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 +44565,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; } } @@ -42956,8 +44578,12 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -42969,7 +44595,7 @@ var ts; entries = getCompletionEntriesFromSymbols(symbols); } // Add keywords if this is not a member completion list - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -42983,7 +44609,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, @@ -42998,18 +44624,28 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } 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 +44685,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 +44717,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 +44781,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 +44819,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 +44828,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 +44841,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 +44858,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 +44874,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 +44893,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 +44919,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 +44927,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 +44935,49 @@ 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); + writeTypeParametersOfSymbol(symbol, sourceFile); 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,26 +44986,39 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } 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 +45026,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 +45062,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 +45100,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 +45121,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 +45131,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 +45162,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 +45210,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 +45219,24 @@ 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); + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } 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 +45244,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 +45274,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 +45305,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 +45348,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 +45362,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 +45388,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 +45441,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 +45527,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 +45558,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 +45579,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 +45595,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 +45623,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 +45652,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 +45662,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 +45693,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 +45725,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 +45740,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 +45761,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 +45784,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 +45799,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 +45816,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 +45830,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 +45868,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 +45935,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 +45950,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 +45958,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 +45976,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 +46039,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 +46066,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 +46099,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 +46127,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 +46170,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 +46203,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 +46256,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 +46291,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 +46306,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 +46339,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 +46365,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 +46444,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 +46480,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 +46495,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 +46571,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 +46583,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 +46625,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 +46661,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 +46679,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 +46688,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 +46771,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 +46793,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 +46829,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 +46893,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 +46903,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 +46964,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 +46996,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 +47040,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 +47048,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 +47092,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 +47128,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 +47137,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 +47146,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 +47177,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 +47271,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 +47313,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 +47403,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 +47425,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 +47470,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 +47504,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 +47584,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47605,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 +47628,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 +47675,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 +47697,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 +47706,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 +47777,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47796,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 +47887,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 +47913,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 +47924,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 +47935,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 +47954,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 +47997,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 +48018,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 +48067,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 +48137,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 +48302,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 +48361,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 +48384,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 +48403,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 +48423,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 +48437,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 +48469,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 +48479,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 +48500,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 +48581,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 +48700,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 +48826,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 +48859,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 +48995,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 +49046,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 +49133,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 +49270,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/package.json b/package.json index 52dabc79f6e..b743b04838d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.6.0", + "version": "1.7.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ @@ -20,6 +20,7 @@ "url": "https://github.com/Microsoft/TypeScript.git" }, "main": "./lib/typescript.js", + "typings": "./lib/typescript.d.ts", "bin": { "tsc": "./bin/tsc", "tsserver": "./bin/tsserver" @@ -49,5 +50,5 @@ "fs": false, "os": false, "path": false - } + } } diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 340bf478209..16f2a59a58d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -973,6 +973,10 @@ namespace ts { else { let bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } let symbol = node.symbol; @@ -1062,4 +1066,4 @@ namespace ts { : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } } -} +} diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 23baadd0762..f71009c7b65 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -388,7 +388,7 @@ namespace ts { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } @@ -1893,7 +1893,7 @@ namespace ts { function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) { let targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) { + if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -3119,7 +3119,7 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -3451,29 +3451,6 @@ namespace 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: Type, name: string): boolean { - if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) { - const resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & TypeFlags.UnionOrIntersection) { - for (let t of (type).types) { - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } - function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { if (type.flags & TypeFlags.StructuredType) { let resolved = resolveStructuredTypeMembers(type); @@ -4103,73 +4080,20 @@ namespace ts { } } - function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean { - let sourceProperties = getPropertiesOfObjectType(source); - let targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (let sourceProp of sourceProperties) { - let targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - - function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean { - let sourceTypes = source.elementTypes; - let 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: Type, target: Type): boolean { - if (source === target) { - return true; - } - if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) { - return true; - } - if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.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: Type, types: Type[]): boolean { - for (let type of types) { - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { + for (let i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types: Type[]) { + function removeSubtypes(types: Type[]) { let i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -4194,12 +4118,14 @@ namespace ts { } } - // 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: Type[], noDeduplication?: boolean): Type { + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type { if (types.length === 0) { return emptyObjectType; } @@ -4208,12 +4134,12 @@ namespace ts { if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -4230,7 +4156,7 @@ namespace ts { function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { let links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); + links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } @@ -4487,6 +4413,15 @@ namespace ts { } function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType { + if (mapper.instantiations) { + let cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it let result = createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -4497,6 +4432,7 @@ namespace ts { let numberIndexType = getIndexTypeOfType(type, IndexKind.Number); if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } @@ -4516,7 +4452,7 @@ namespace ts { return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); } if (type.flags & TypeFlags.Union) { - return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noDeduplication*/ true); + return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & TypeFlags.Intersection) { return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); @@ -4612,7 +4548,7 @@ namespace ts { * @param target The right-hand-side of the relation. * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param errorNode The node upon which all errors will be reported, if defined. + * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ @@ -4803,11 +4739,41 @@ namespace ts { return Ternary.False; } + // 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 and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type: Type, name: string): boolean { + if (type.flags & TypeFlags.ObjectType) { + const resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & TypeFlags.UnionOrIntersection) { + for (let t of (type).types) { + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { for (let prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { - reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + // We know *exactly* where things went wrong when comparing the types. + // Use this property as the error node as this will be more helpful in + // reasoning about what went wrong. + errorNode = prop.valueDeclaration + reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(prop), + typeToString(target)); } return true; } @@ -5584,7 +5550,7 @@ namespace ts { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & TypeFlags.Union) { - return getUnionType(map((type).types, getWidenedType)); + return getUnionType(map((type).types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType((type).typeArguments[0])); @@ -7151,7 +7117,7 @@ namespace ts { let propertiesTable: SymbolTable = {}; let propertiesArray: Symbol[] = []; let contextualType = getContextualType(node); - let typeFlags: TypeFlags; + let typeFlags: TypeFlags = 0; for (let memberDecl of node.properties) { let member = memberDecl.symbol; @@ -7200,7 +7166,8 @@ namespace ts { let stringIndexType = getIndexType(IndexKind.String); let numberIndexType = getIndexType(IndexKind.Number); let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags); + let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral; + result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); return result; function getIndexType(kind: IndexKind) { @@ -11384,9 +11351,16 @@ namespace ts { // serialize the type metadata. if (node && node.kind === SyntaxKind.TypeReference) { let root = getFirstIdentifier((node).typeName); - let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + let meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace; + // Resolve type so we know which symbol is referenced + let rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) { + let aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -12596,6 +12570,7 @@ namespace ts { if (baseTypes.length && produceDiagnostics) { let baseType = baseTypes[0]; let staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { forEach(baseTypeNode.typeArguments, checkSourceElement); for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { @@ -13046,7 +13021,7 @@ namespace ts { // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { reportError = false; - error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); + error(e, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } @@ -13665,6 +13640,8 @@ namespace ts { case SyntaxKind.VariableDeclaration: case SyntaxKind.VariableDeclarationList: case SyntaxKind.ClassDeclaration: + case SyntaxKind.HeritageClause: + case SyntaxKind.ExpressionWithTypeArguments: case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: case SyntaxKind.ExportAssignment: @@ -14402,6 +14379,10 @@ namespace ts { // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. let typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return TypeReferenceSerializationKind.ObjectType; + } let type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return TypeReferenceSerializationKind.Unknown; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 9a984b9a2f1..c56a18b3ab2 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -30,6 +30,11 @@ namespace ts { type: "boolean", description: Diagnostics.Print_this_message, }, + { + name: "init", + type: "boolean", + description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, { name: "inlineSourceMap", type: "boolean", @@ -120,6 +125,13 @@ namespace ts { { name: "out", type: "string", + isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files + // for correct behaviour, please use outFile + paramType: Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", isFilePath: true, description: Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: Diagnostics.FILE, @@ -172,6 +184,12 @@ namespace ts { description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: Diagnostics.LOCATION, }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -218,22 +236,49 @@ namespace ts { type: "boolean", experimental: true, description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - } + }, + { + name: "moduleResolution", + type: { + "node": ModuleResolutionKind.NodeJs, + "classic": ModuleResolutionKind.Classic + }, + description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 + } ]; - export function parseCommandLine(commandLine: string[]): ParsedCommandLine { - let options: CompilerOptions = {}; - let fileNames: string[] = []; - let errors: Diagnostic[] = []; - let shortOptionNames: Map = {}; - let optionNameMap: Map = {}; + /* @internal */ + export interface OptionNameMap { + optionNameMap: Map; + shortOptionNames: Map; + } + let optionNameMapCache: OptionNameMap; + /* @internal */ + export function getOptionNameMap(): OptionNameMap { + if (optionNameMapCache) { + return optionNameMapCache; + } + + let optionNameMap: Map = {}; + let shortOptionNames: Map = {}; forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + + optionNameMapCache = { optionNameMap, shortOptionNames }; + return optionNameMapCache; + } + + export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine { + let options: CompilerOptions = {}; + let fileNames: string[] = []; + let errors: Diagnostic[] = []; + let { optionNameMap, shortOptionNames } = getOptionNameMap(); + parseStrings(commandLine); return { options, @@ -297,7 +342,7 @@ namespace ts { } function parseResponseFile(fileName: string) { - let text = sys.readFile(fileName); + let text = readFile ? readFile(fileName) : sys.readFile(fileName); if (!text) { errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName)); @@ -450,4 +495,4 @@ namespace ts { return fileNames; } } -} +} \ No newline at end of file diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 5fc9335073c..a1f6565ed1f 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -287,14 +287,14 @@ namespace ts { return result; } - export function extend(first: Map, second: Map): Map { - let result: Map = {}; + export function extend(first: Map, second: Map): Map { + let result: Map = {}; for (let id in first) { - result[id] = first[id]; + (result as any)[id] = first[id]; } for (let id in second) { if (!hasProperty(result, id)) { - result[id] = second[id]; + (result as any)[id] = second[id]; } } return result; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index a490ba39a46..e5914d10060 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -896,6 +896,9 @@ namespace ts { if (isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; @@ -1574,7 +1577,7 @@ namespace ts { ? referencedFile.fileName // Declaration file, use declaration file name : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = getRelativePathToDirectoryOrUrl( getDirectoryPath(normalizeSlashes(jsFilePath)), diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 5ccc0a0db9b..f7351bf6912 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -425,7 +425,7 @@ namespace ts { JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: 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: 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: 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: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: 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: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, @@ -506,19 +506,12 @@ namespace ts { Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: 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: 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: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: 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: 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: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -569,11 +562,14 @@ namespace ts { Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: 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: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: 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: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e138e2ddac4..9fd08ef9bca 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -161,7 +161,7 @@ }, "Type '{0}' is not a valid async function return type.": { "category": "Error", - "code": 1055 + "code": 1055 }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", @@ -1689,7 +1689,7 @@ "category": "Error", "code": 2650 }, - "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": { + "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": { "category": "Error", "code": 2651 }, @@ -2013,58 +2013,30 @@ "category": "Error", "code": 5033 }, - "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option.": { - "category": "Error", - "code": 5038 - }, - "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option.": { - "category": "Error", - "code": 5039 - }, - "Option 'noEmit' cannot be specified with option 'out' or 'outDir'.": { - "category": "Error", - "code": 5040 - }, - "Option 'noEmit' cannot be specified with option 'declaration'.": { - "category": "Error", - "code": 5041 - }, "Option 'project' cannot be mixed with source files on a command line.": { "category": "Error", "code": 5042 }, - "Option 'declaration' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5044 - }, - "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5045 - }, - "Option 'out' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5046 - }, "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": { "category": "Error", "code": 5047 }, - "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5048 - }, - "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5049 - }, - "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5050 - }, "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, + "Option '{0}' cannot be specified without specifying option '{1}'.": { + "category": "Error", + "code": 5052 + }, + "Option '{0}' cannot be specified with option '{1}'.": { + "category": "Error", + "code": 5053 + }, + "A 'tsconfig.json' file is already defined at: '{0}'.": { + "category": "Error", + "code": 5053 + }, "Concatenate and emit output to single file.": { "category": "Message", @@ -2266,10 +2238,6 @@ "category": "Message", "code": 6081 }, - "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { - "category": "Error", - "code": 6064 - }, "Enables experimental support for ES7 decorators.": { "category": "Message", "code": 6065 @@ -2286,6 +2254,22 @@ "category": "Message", "code": 6068 }, + "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .": { + "category": "Message", + "code": 6069 + }, + "Initializes a TypeScript project and creates a tsconfig.json file.": { + "category": "Message", + "code": 6070 + }, + "Successfully created a tsconfig.json file.": { + "category": "Message", + "code": 6071 + }, + "Suppress excess property checks for object literals.": { + "category": "Message", + "code": 6072 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a6e9b22ddee..eeaab6d2123 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -78,18 +78,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } }); - 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 (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } @@ -124,11 +124,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitJavaScript(jsFilePath: string, root?: SourceFile) { let writer = createTextWriter(newLine); - let write = writer.write; - let writeTextOfNode = writer.writeTextOfNode; - let writeLine = writer.writeLine; - let increaseIndent = writer.increaseIndent; - let decreaseIndent = writer.decreaseIndent; + let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer; let currentSourceFile: SourceFile; // name of an exporter function if file is a System external module @@ -1181,9 +1177,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { + let syntheticReactRef = createSynthesizedNode(SyntaxKind.Identifier); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); @@ -1197,7 +1198,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // a call to React.__spread let attrs = openingNode.attributes; if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); let haveOpenedObjectLiteral = false; for (let i = 0; i < attrs.length; i++) { @@ -1519,7 +1521,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } } - writeTextOfNode(currentSourceFile, node); + + if (nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node: Identifier) { @@ -1546,6 +1554,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -2105,7 +2116,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } - + function emitQualifiedName(node: QualifiedName) { emit(node.left); write("."); @@ -2128,12 +2139,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { emitEntityNameAsExpression(node.left, /*useFallback*/ false); } - + write("."); emit(node.right); } - - function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) { + + function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) { switch (node.kind) { case SyntaxKind.Identifier: if (useFallback) { @@ -2141,10 +2152,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExpressionIdentifier(node); write(" !== 'undefined' && "); } - + emitExpressionIdentifier(node); break; - + case SyntaxKind.QualifiedName: emitQualifiedNameAsExpression(node, useFallback); break; @@ -3055,7 +3066,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === ScriptTarget.ES5) { - // default value of configurable, enumerable, writable are `false`. + // default value of configurable, enumerable, writable are `false`. write("Object.defineProperty(exports, \"__esModule\", { value: true });"); writeLine(); } @@ -4311,7 +4322,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi 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); + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); @@ -4883,7 +4894,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return false; } - + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ function emitSerializedTypeOfNode(node: Node) { // serialization of the type of a declaration uses the following rules: @@ -4894,39 +4905,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { case SyntaxKind.ClassDeclaration: write("Function"); return; - - case SyntaxKind.PropertyDeclaration: + + case SyntaxKind.PropertyDeclaration: emitSerializedTypeNode((node).type); return; - - case SyntaxKind.Parameter: + + case SyntaxKind.Parameter: emitSerializedTypeNode((node).type); return; - - case SyntaxKind.GetAccessor: + + case SyntaxKind.GetAccessor: emitSerializedTypeNode((node).type); return; - - case SyntaxKind.SetAccessor: + + case SyntaxKind.SetAccessor: emitSerializedTypeNode(getSetAccessorTypeAnnotationNode(node)); return; - + } - + if (isFunctionLike(node)) { write("Function"); return; } - + write("void 0"); } - + function emitSerializedTypeNode(node: TypeNode) { if (!node) { return; @@ -4940,17 +4951,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.ParenthesizedType: emitSerializedTypeNode((node).type); return; - + case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: write("Function"); return; - + case SyntaxKind.ArrayType: case SyntaxKind.TupleType: write("Array"); return; - + case SyntaxKind.TypePredicate: case SyntaxKind.BooleanKeyword: write("Boolean"); @@ -4960,11 +4971,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.StringLiteral: write("String"); return; - + case SyntaxKind.NumberKeyword: write("Number"); return; - + case SyntaxKind.SymbolKeyword: write("Symbol"); return; @@ -4972,22 +4983,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.TypeReference: emitSerializedTypeReferenceNode(node); return; - + case SyntaxKind.TypeQuery: case SyntaxKind.TypeLiteral: case SyntaxKind.UnionType: case SyntaxKind.IntersectionType: case SyntaxKind.AnyKeyword: break; - + default: Debug.fail("Cannot serialize unexpected type node."); break; } - + write("Object"); } - + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node: TypeReferenceNode) { let location: Node = node.parent; @@ -5015,27 +5026,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; - + case TypeReferenceSerializationKind.VoidType: write("void 0"); break; - + case TypeReferenceSerializationKind.BooleanType: write("Boolean"); break; - + case TypeReferenceSerializationKind.NumberLikeType: write("Number"); break; - + case TypeReferenceSerializationKind.StringLikeType: write("String"); break; - + case TypeReferenceSerializationKind.ArrayLikeType: write("Array"); break; - + case TypeReferenceSerializationKind.ESSymbolType: if (languageVersion < ScriptTarget.ES6) { write("typeof Symbol === 'function' ? Symbol : Object"); @@ -5044,24 +5055,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("Symbol"); } break; - + case TypeReferenceSerializationKind.TypeWithCallSignature: write("Function"); break; - + case TypeReferenceSerializationKind.ObjectType: write("Object"); break; } } - + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ function emitSerializedParameterTypesOfNode(node: Node) { // serialization of parameter types uses the following rules: // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { let valueDeclaration: FunctionLikeDeclaration; @@ -5071,7 +5082,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else if (isFunctionLike(node) && nodeIsPresent((node).body)) { valueDeclaration = node; } - + if (valueDeclaration) { const parameters = valueDeclaration.parameters; const parameterCount = parameters.length; @@ -5080,7 +5091,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (i > 0) { write(", "); } - + if (parameters[i].dotDotDotToken) { let parameterType = parameters[i].type; if (parameterType.kind === SyntaxKind.ArrayType) { @@ -5092,7 +5103,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { parameterType = undefined; } - + emitSerializedTypeNode(parameterType); } else { @@ -5103,18 +5114,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } - + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node: Node): string | string[] { if (node && isFunctionLike(node) && (node).type) { emitSerializedTypeNode((node).type); return; } - + write("void 0"); } - - + + function emitSerializedTypeMetadata(node: Declaration, writeComma: boolean): number { // This method emits the serialized type metadata for a decorator target. // The caller should have already tested whether the node has decorators. @@ -5131,7 +5142,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { - debugger; if (writeComma || argumentsWritten) { write(", "); } @@ -5145,7 +5155,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (writeComma || argumentsWritten) { write(", "); } - + writeLine(); write("__metadata('design:returntype', "); emitSerializedReturnTypeOfNode(node); @@ -5153,10 +5163,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi argumentsWritten++; } } - + return argumentsWritten; } - + function emitInterfaceDeclaration(node: InterfaceDeclaration) { emitOnlyPinnedOrTripleSlashComments(node); } @@ -5522,18 +5532,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi (!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - + // 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 let 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) let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); - + if (!variableDeclarationIsHoisted) { Debug.assert(!isExported); - + if (isES6ExportedDeclaration(node)) { write("export "); write("var "); @@ -5542,8 +5552,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("var "); } } - - + + if (isExported) { write(`${exportFunctionForFile}("`); emitNodeWithoutSourceMap(node.name); @@ -5557,8 +5567,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (isExported) { write(")"); } - - write(";"); + + write(";"); emitEnd(node); emitExportImportAssignments(node); emitTrailingComments(node); @@ -6080,12 +6090,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return; } - + if (isInternalModuleImportEqualsDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } - + hoistedVars.push(node.name); return; } @@ -6513,9 +6523,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function trimReactWhitespace(node: JsxText): string { + function trimReactWhitespaceAndApplyEntities(node: JsxText): string { let result: string = undefined; - let text = getTextOfNode(node); + let text = getTextOfNode(node, /*includeTrivia*/ true); let firstNonWhitespace = 0; let lastNonWhitespace = -1; @@ -6538,19 +6548,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } + if (firstNonWhitespace !== -1) { let part = text.substr(firstNonWhitespace); result = (result ? result + "\" + ' ' + \"" : "") + part; } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function(s: any, m: string) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; } function getTextToEmit(node: JsxText) { switch (compilerOptions.jsx) { case JsxEmit.React: - let text = trimReactWhitespace(node); - if (text.length === 0) { + let text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -6558,7 +6581,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } case JsxEmit.Preserve: default: - return getTextOfNode(node, true); + return getTextOfNode(node, /*includeTrivia*/ true); } } @@ -6566,13 +6589,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi switch (compilerOptions.jsx) { case JsxEmit.React: write("\""); - write(trimReactWhitespace(node)); + write(trimReactWhitespaceAndApplyEntities(node)); write("\""); break; case JsxEmit.Preserve: default: // Emit JSX-preserve as default when no --jsx flag is specified - writer.writeLiteral(getTextOfNode(node, true)); + writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); break; } } @@ -7139,4 +7162,260 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } + + var entities: Map = { + "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 + } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index def08e81758..350b9d450b8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4941,12 +4941,15 @@ namespace ts { function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration { let node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + // If we are parsing a dotted namespace name, we want to + // propagate the 'Namespace' flag across the names if set. + let namespaceFlag = flags & NodeFlags.Namespace; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(SyntaxKind.DotToken) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -5831,7 +5834,6 @@ namespace ts { if (!name) { parseErrorAtPosition(pos, 0, Diagnostics.Identifier_expected); - return undefined; } let preName: Identifier, postName: Identifier; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ceb4e5fb033..402b413dd9c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1,5 +1,6 @@ /// /// +/// namespace ts { /* @internal */ export let programTime = 0; @@ -11,7 +12,7 @@ namespace ts { let emptyArray: any[] = []; - export const version = "1.6.0"; + export const version = "1.7.0"; export function findConfigFile(searchPath: string): string { let fileName = "tsconfig.json"; @@ -36,11 +37,150 @@ namespace ts { } export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { - // TODO: use different resolution strategy based on compiler options - return legacyNameResolver(moduleName, containingFile, compilerOptions, host); + let moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic; + + switch (moduleResolution) { + case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, host); + case ModuleResolutionKind.Classic: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + + export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule { + let containingDirectory = getDirectoryPath(containingFile); + + if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + let failedLookupLocations: string[] = []; + let candidate = normalizePath(combinePaths(containingDirectory, moduleName)); + let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + + if (resolvedFileName) { + return { resolvedFileName, failedLookupLocations }; + } + + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return { resolvedFileName, failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + + function loadNodeModuleFromFile(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return forEach(supportedExtensions, tryLoad); + } + + function tryLoad(ext: string): string { + let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + + function loadNodeModuleFromDirectory(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string { + let packageJsonPath = combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + + let jsonContent: { typings?: string }; + + try { + let jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + + if (jsonContent.typings) { + let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + + return loadNodeModuleFromFile(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + + function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModule { + let failedLookupLocations: string[] = []; + directory = normalizeSlashes(directory); + while (true) { + let baseName = getBaseFileName(directory); + if (baseName !== "node_modules") { + let nodeModulesFolder = combinePaths(directory, "node_modules"); + let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); + let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations }; + } + + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations }; + } + } + + let parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + + directory = parentPath; + } + + return { resolvedFileName: undefined, failedLookupLocations }; + } + + export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule { + Debug.assert(baseUrl !== undefined); + + let normalizedModuleName = normalizeSlashes(moduleName); + let basePart = useBaseUrl(moduleName) ? baseUrl : getDirectoryPath(containingFile); + let candidate = normalizePath(combinePaths(basePart, moduleName)); + + let failedLookupLocations: string[] = []; + + return forEach(supportedExtensions, ext => tryLoadFile(candidate + ext)) || { resolvedFileName: undefined, failedLookupLocations }; + + function tryLoadFile(location: string): ResolvedModule { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + + function nameStartsWithDotSlashOrDotDotSlash(name: string) { + let i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot); + } + + function useBaseUrl(moduleName: string): boolean { + // path is not rooted + // module name does not start with './' or '../' + return getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); } - function legacyNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { // module names that contain '!' are used to reference resources and are not resolved to actual files on disk if (moduleName.indexOf('!') != -1) { @@ -85,6 +225,16 @@ namespace ts { return { resolvedFileName: referencedSourceFile, failedLookupLocations }; } + /* @internal */ + export const defaultInitCompilerOptions: CompilerOptions = { + module: ModuleKind.CommonJS, + target: ScriptTarget.ES3, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false, + }; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { let currentDirectory: string; let existingDirectories: Map = {}; @@ -221,19 +371,9 @@ namespace ts { host = host || createCompilerHost(options); - // initialize resolveModuleNameWorker only if noResolve is false - let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => string[]; - if (!options.noResolve) { - resolveModuleNamesWorker = host.resolveModuleNames; - if (!resolveModuleNamesWorker) { - resolveModuleNamesWorker = (moduleNames, containingFile) => { - return map(moduleNames, moduleName => { - let moduleResolution = resolveModuleName(moduleName, containingFile, options, host); - return moduleResolution.resolvedFileName; - }); - } - } - } + const resolveModuleNamesWorker = + host.resolveModuleNames || + ((moduleNames, containingFile) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedFileName)); let filesByName = createFileMap(fileName => host.getCanonicalFileName(fileName)); @@ -340,7 +480,7 @@ namespace ts { } // check imports - collectExternalModuleReferences(newSourceFile); + collectExternalModuleReferences(newSourceFile); if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed return false; @@ -423,7 +563,7 @@ namespace 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. - let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out)? undefined : sourceFile); let start = new Date().getTime(); @@ -670,12 +810,15 @@ namespace ts { // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); - + + let basePath = getDirectoryPath(fileName); if (!options.noResolve) { - let basePath = 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); @@ -713,21 +856,19 @@ namespace ts { }); } - function processImportedModules(file: SourceFile, basePath: string) { - collectExternalModuleReferences(file); - if (file.imports.length) { + function processImportedModules(file: SourceFile, basePath: string) { + collectExternalModuleReferences(file); + if (file.imports.length) { file.resolvedModules = {}; - let oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName); - let moduleNames = map(file.imports, name => name.text); let resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); for (let i = 0; i < file.imports.length; ++i) { let resolution = resolutions[i]; setResolvedModuleName(file, moduleNames[i], resolution); - if (resolution) { + if (resolution && !options.noResolve) { findModuleSourceFile(resolution, file.imports[i]); } - } + } } else { // no imports - drop cached module resolutions @@ -803,27 +944,31 @@ namespace ts { function verifyCompilerOptions() { if (options.isolatedModules) { if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + + if (options.outFile) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } @@ -834,18 +979,23 @@ namespace ts { } } + if (options.out && options.outFile) { + diagnostics.add(createCompilerDiagnostic(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(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } let languageVersion = options.target || ScriptTarget.ES3; + let outFile = options.outFile || options.out; let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); if (options.isolatedModules) { @@ -875,7 +1025,7 @@ namespace ts { if (options.outDir || // there is --outDir specified options.sourceRoot || // there is --sourceRoot specified (options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated - (!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 @@ -895,18 +1045,26 @@ namespace ts { } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + + if (options.outFile) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + + if (options.outDir) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 2f73c9c8820..199e7e9b638 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -472,7 +472,7 @@ namespace ts { break; case CharacterCodes.hash: - if (isShebangTrivia(text, pos)) { + if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); continue; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index c322187fa14..8c0a6d4e8c4 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -159,6 +159,11 @@ namespace ts { return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } + if (commandLine.options.init) { + writeConfigFile(commandLine.options, commandLine.fileNames); + return sys.exit(ExitStatus.Success); + } + if (commandLine.options.version) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); return sys.exit(ExitStatus.Success); @@ -489,6 +494,70 @@ namespace ts { return Array(paddingLength + 1).join(" "); } } + + function writeConfigFile(options: CompilerOptions, fileNames: string[]) { + let currentDirectory = sys.getCurrentDirectory(); + let file = combinePaths(currentDirectory, 'tsconfig.json'); + if (sys.fileExists(file)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + } + else { + let compilerOptions = extend(options, defaultInitCompilerOptions); + let configurations: any = { + compilerOptions: serializeCompilerOptions(compilerOptions), + exclude: ["node_modules"] + }; + + if (fileNames && fileNames.length) { + // only set the files property if we have at least one file + configurations.files = fileNames; + } + + sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file)); + } + + return; + + function serializeCompilerOptions(options: CompilerOptions): Map { + let result: Map = {}; + let optionsNameMap = getOptionNameMap().optionNameMap; + + for (let name in options) { + if (hasProperty(options, name)) { + let value = options[name]; + switch (name) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + let optionDefinition = optionsNameMap[name.toLowerCase()]; + if (optionDefinition) { + if (typeof optionDefinition.type === "string") { + // string, number or boolean + result[name] = value; + } + else { + // Enum + let typeMap = >optionDefinition.type; + for (let key in typeMap) { + if (hasProperty(typeMap, key)) { + if (typeMap[key] === value) + result[name] = key; + } + } + } + } + break; + } + } + } + return result; + } + } } ts.executeCommandLine(ts.sys.args); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1338d19e1a7..47182e39527 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1411,6 +1411,7 @@ namespace ts { /* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps } + /* @internal */ export interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; @@ -1551,8 +1552,8 @@ namespace ts { export interface SymbolAccessiblityResult extends SymbolVisibilityResult { errorModuleName?: string; // If the symbol is not visible from module, module's name } - - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator * metadata */ /* @internal */ export enum TypeReferenceSerializationKind { @@ -1952,6 +1953,7 @@ namespace ts { /* @internal */ export interface TypeMapper { (t: TypeParameter): Type; + instantiations?: Type[]; // Cache of instantiations created using this type mapper. context?: InferenceContext; // The inference context this mapper was created from. // Only inference mappers have this set (in createInferenceMapper). // The identity mapper and regular instantiation mappers do not need it. @@ -2008,7 +2010,12 @@ namespace ts { Error, Message, } - + + export const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2 + } + export interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -2016,6 +2023,7 @@ namespace ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -2032,6 +2040,7 @@ namespace ts { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -2039,6 +2048,7 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; @@ -2047,6 +2057,7 @@ namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0847d1d7829..99ea06532a0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -240,7 +240,7 @@ namespace ts { // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores export function makeIdentifierFromModuleName(moduleName: string): string { - return getBaseFileName(moduleName).replace(/\W/g, "_"); + return getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } export function isBlockOrCatchScoped(declaration: Declaration) { @@ -611,11 +611,11 @@ namespace ts { return false; } - export function isAccessor(node: Node): boolean { + export function isAccessor(node: Node): node is AccessorDeclaration { return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor); } - export function isClassLike(node: Node): boolean { + export function isClassLike(node: Node): node is ClassLikeDeclaration { return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); } @@ -978,6 +978,7 @@ namespace ts { case SyntaxKind.ComputedPropertyName: return node === (parent).expression; case SyntaxKind.Decorator: + case SyntaxKind.JsxExpression: return true; case SyntaxKind.ExpressionWithTypeArguments: return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); @@ -1766,7 +1767,7 @@ namespace ts { export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean { 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 || !fileExtensionIs(sourceFile.fileName, ".js"); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 1d2ad83d98a..5bfac3d9bb5 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -123,18 +123,20 @@ module FourSlash { mapRoot: "mapRoot", module: "module", out: "out", + outFile: "outFile", outDir: "outDir", sourceMap: "sourceMap", sourceRoot: "sourceRoot", allowNonTsExtensions: "allowNonTsExtensions", resolveReference: "ResolveReference", // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file + jsx: "jsx", }; // List of allowed metadata names let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; let globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration, - metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out, - metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]; + metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,metadataOptionNames.outFile, + metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot, metadataOptionNames.jsx]; function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions { let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; @@ -169,6 +171,9 @@ module FourSlash { case metadataOptionNames.out: settings.out = globalOptions[prop]; break; + case metadataOptionNames.outFile: + settings.outFile = globalOptions[prop]; + break; case metadataOptionNames.outDir: settings.outDir = globalOptions[prop]; break; @@ -178,6 +183,20 @@ module FourSlash { case metadataOptionNames.sourceRoot: settings.sourceRoot = globalOptions[prop]; break; + case metadataOptionNames.jsx: + switch (globalOptions[prop].toLowerCase()) { + case "react": + settings.jsx = ts.JsxEmit.React; + break; + case "preserve": + settings.jsx = ts.JsxEmit.Preserve; + break; + default: + ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None"); + settings.jsx = ts.JsxEmit.None; + break; + } + break; } } } @@ -358,7 +377,7 @@ module FourSlash { this.formatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys.newLine, + NewLineCharacter: Harness.IO.newLine(), ConvertTabsToSpaces: true, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, @@ -536,7 +555,7 @@ module FourSlash { errors.forEach(function (error: ts.Diagnostic) { Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + - ", message: " + ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine) + "\n"); + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n"); }); } @@ -1247,21 +1266,21 @@ module FourSlash { emitFiles.forEach(emitFile => { let emitOutput = this.languageService.getEmitOutput(emitFile.fileName); // Print emitOutputStatus in readable format - resultString += "EmitSkipped: " + emitOutput.emitSkipped + ts.sys.newLine; + resultString += "EmitSkipped: " + emitOutput.emitSkipped + Harness.IO.newLine(); if (emitOutput.emitSkipped) { - resultString += "Diagnostics:" + ts.sys.newLine; + resultString += "Diagnostics:" + Harness.IO.newLine(); let diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram()); for (let i = 0, n = diagnostics.length; i < n; i++) { - resultString += " " + diagnostics[0].messageText + ts.sys.newLine; + resultString += " " + diagnostics[0].messageText + Harness.IO.newLine(); } } emitOutput.outputFiles.forEach((outputFile, idx, array) => { - let fileName = "FileName : " + outputFile.name + ts.sys.newLine; + let fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); resultString = resultString + fileName + outputFile.text; }); - resultString += ts.sys.newLine; + resultString += Harness.IO.newLine(); }); return resultString; @@ -1298,7 +1317,7 @@ module FourSlash { Harness.IO.log( "start: " + err.start + ", length: " + err.length + - ", message: " + ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine)); + ", message: " + ts.flattenDiagnosticMessageText(err.messageText, Harness.IO.newLine())); }); } } @@ -1872,9 +1891,9 @@ module FourSlash { } function jsonMismatchString() { - return ts.sys.newLine + - "expected: '" + ts.sys.newLine + JSON.stringify(expected, (k, v) => v, 2) + "'" + ts.sys.newLine + - "actual: '" + ts.sys.newLine + JSON.stringify(actual, (k, v) => v, 2) + "'"; + return Harness.IO.newLine() + + "expected: '" + Harness.IO.newLine() + JSON.stringify(expected, (k, v) => v, 2) + "'" + Harness.IO.newLine() + + "actual: '" + Harness.IO.newLine() + JSON.stringify(actual, (k, v) => v, 2) + "'"; } } @@ -2383,7 +2402,7 @@ module FourSlash { let host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFileName, content: undefined }], (fn, contents) => fourslashJsOutput = contents, ts.ScriptTarget.Latest, - ts.sys.useCaseSensitiveFileNames); + Harness.IO.useCaseSensitiveFileNames()); let program = ts.createProgram([Harness.Compiler.fourslashFileName], { noResolve: true, target: ts.ScriptTarget.ES3 }, host); @@ -2405,16 +2424,16 @@ module FourSlash { ], (fn, contents) => result = contents, ts.ScriptTarget.Latest, - ts.sys.useCaseSensitiveFileNames); + Harness.IO.useCaseSensitiveFileNames()); - let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); + let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); let sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3); let diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); if (diagnostics.length > 0) { throw new Error(`Error compiling ${fileName}: ` + - diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join("\r\n")); + diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, Harness.IO.newLine())).join("\r\n")); } program.emit(sourceFile); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a0366c0c40b..f65a4f88730 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -26,7 +26,6 @@ // Block scoped definitions work poorly for global variables, temporarily enable var /* tslint:disable:no-var-keyword */ -var Buffer: BufferConstructor = require("buffer").Buffer; // this will work in the browser via browserify var _chai: typeof chai = require("chai"); @@ -55,9 +54,17 @@ module Utils { return ExecutionEnvironment.Node; } } - + export let currentExecutionEnvironment = getExecutionEnvironment(); + const Buffer: BufferConstructor = currentExecutionEnvironment !== ExecutionEnvironment.Browser + ? require("buffer").Buffer + : undefined; + + export function encodeString(s: string): string { + return Buffer ? (new Buffer(s)).toString("utf8") : s; + } + export function evalFile(fileContents: string, fileName: string, nodeContext?: any) { let environment = getExecutionEnvironment(); switch (environment) { @@ -102,7 +109,7 @@ module Utils { let content: string = undefined; try { - content = ts.sys.readFile(Harness.userSpecifiedRoot + path); + content = Harness.IO.readFile(Harness.userSpecifiedRoot + path); } catch (err) { return undefined; @@ -190,7 +197,7 @@ module Utils { return { start: diagnostic.start, length: diagnostic.length, - messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine), + messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()), category: (ts).DiagnosticCategory[diagnostic.category], code: diagnostic.code }; @@ -323,8 +330,8 @@ module Utils { assert.equal(d1.start, d2.start, "d1.start !== d2.start"); assert.equal(d1.length, d2.length, "d1.length !== d2.length"); assert.equal( - ts.flattenDiagnosticMessageText(d1.messageText, ts.sys.newLine), - ts.flattenDiagnosticMessageText(d2.messageText, ts.sys.newLine), "d1.messageText !== d2.messageText"); + ts.flattenDiagnosticMessageText(d1.messageText, Harness.IO.newLine()), + ts.flattenDiagnosticMessageText(d2.messageText, Harness.IO.newLine()), "d1.messageText !== d2.messageText"); assert.equal(d1.category, d2.category, "d1.category !== d2.category"); assert.equal(d1.code, d2.code, "d1.code !== d2.code"); } @@ -404,6 +411,10 @@ module Harness.Path { module Harness { export interface IO { + newLine(): string; + getCurrentDirectory(): string; + useCaseSensitiveFileNames(): boolean; + resolvePath(path: string): string; readFile(path: string): string; writeFile(path: string, contents: string): void; directoryName(path: string): string; @@ -414,9 +425,15 @@ module Harness { listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; getMemoryUsage?(): number; + args(): string[]; + getExecutingFilePath(): string; + exit(exitCode?: number): void; } export var IO: IO; - + + // harness always uses one kind of new line + const harnessNewLine = "\r\n"; + module IOImpl { declare class Enumerator { public atEnd(): boolean; @@ -432,13 +449,21 @@ module Harness { } else { fso = {}; } + + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); + export const resolvePath = (path: string) => ts.sys.resolvePath(path); + export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; - export let readFile: typeof IO.readFile = ts.sys.readFile; - export let writeFile: typeof IO.writeFile = ts.sys.writeFile; - export let directoryName: typeof IO.directoryName = fso.GetParentFolderName; - export let directoryExists: typeof IO.directoryExists = fso.FolderExists; - export let fileExists: typeof IO.fileExists = fso.FileExists; - export let log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; + export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); + export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); + export const directoryName: typeof IO.directoryName = fso.GetParentFolderName; + export const directoryExists: typeof IO.directoryExists = fso.FolderExists; + export const fileExists: typeof IO.fileExists = fso.FileExists; + export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; export function createDirectory(path: string) { if (directoryExists(path)) { @@ -493,11 +518,19 @@ module Harness { } else { fs = pathModule = {}; } + + export const resolvePath = (path: string) => ts.sys.resolvePath(path); + export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); - export let readFile: typeof IO.readFile = ts.sys.readFile; - export let writeFile: typeof IO.writeFile = ts.sys.writeFile; - export let fileExists: typeof IO.fileExists = fs.existsSync; - export let log: typeof IO.log = s => console.log(s); + export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); + export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); + export const fileExists: typeof IO.fileExists = fs.existsSync; + export const log: typeof IO.log = s => console.log(s); export function createDirectory(path: string) { if (!directoryExists(path)) { @@ -562,9 +595,13 @@ module Harness { export module Network { let serverRoot = "http://localhost:8888/"; - // Unused? - let newLine = "\r\n"; - let currentDirectory = () => ""; + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => false; + export const getCurrentDirectory = () => ""; + export const args = () => []; + export const getExecutingFilePath = () => ""; + export const exit = (exitCode: number) => {}; + let supportsCodePage = () => false; module Http { @@ -616,6 +653,7 @@ module Harness { xhr.send(contents); } catch (e) { + log(`XHR Error: ${e}`); return { status: 500, responseText: null }; } @@ -655,6 +693,7 @@ module Harness { return dirPath; } export let directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl); + export const resolvePath = (path: string) => directoryName(path); export function fileExists(path: string): boolean { let response = Http.getFileFromServerSync(serverRoot + path); @@ -840,7 +879,7 @@ module Harness { export let fourslashSourceFile: ts.SourceFile; export function getCanonicalFileName(fileName: string): string { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return Harness.IO.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase(); } export function createCompilerHost( @@ -858,7 +897,7 @@ module Harness { } let filemap: { [fileName: string]: ts.SourceFile; } = {}; - let getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory; + let getCurrentDirectory = currentDirectory === undefined ? Harness.IO.getCurrentDirectory : () => currentDirectory; // Register input files function register(file: { unitName: string; content: string; }) { @@ -895,7 +934,7 @@ module Harness { let newLine = newLineKind === ts.NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed : newLineKind === ts.NewLineKind.LineFeed ? lineFeed : - ts.sys.newLine; + Harness.IO.newLine(); return { getCurrentDirectory, @@ -988,7 +1027,7 @@ module Harness { // Treat them as library files, so include them in build, but not in baselines. let includeBuiltFiles: { unitName: string; content: string }[] = []; - let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; + let useCaseSensitiveFileNames = Harness.IO.useCaseSensitiveFileNames(); this.settings.forEach(setCompilerOptionForSetting); let fileOutputs: GeneratedFile[] = []; @@ -1006,11 +1045,9 @@ module Harness { let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); this.lastErrors = errors; - let result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); + let result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps); onComplete(result, program); - // reset what newline means in case the last test changed it - ts.sys.newLine = newLine; return options; function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { @@ -1025,6 +1062,13 @@ module Harness { options.module = ts.ModuleKind.UMD; } else if (setting.value.toLowerCase() === "commonjs") { options.module = ts.ModuleKind.CommonJS; + if (options.moduleResolution === undefined) { + // TODO: currently we have relative module names pretty much in all tests that use CommonJS module target. + // Such names could never be resolved in Node however classic resolution strategy still can handle them. + // Changing all module names to relative will be a major overhaul in code (but we'll do this anyway) so as a temporary measure + // we'll use ts.ModuleResolutionKind.Classic for CommonJS modules. + options.moduleResolution = ts.ModuleResolutionKind.Classic; + } } else if (setting.value.toLowerCase() === "system") { options.module = ts.ModuleKind.System; } else if (setting.value.toLowerCase() === "unspecified") { @@ -1036,7 +1080,16 @@ module Harness { options.module = setting.value; } break; - + case "moduleresolution": + switch((setting.value || "").toLowerCase()) { + case "classic": + options.moduleResolution = ts.ModuleResolutionKind.Classic; + break; + case "node": + options.moduleResolution = ts.ModuleResolutionKind.NodeJs; + break; + } + break; case "target": case "codegentarget": if (typeof setting.value === "string") { @@ -1091,6 +1144,10 @@ module Harness { options.out = setting.value; break; + case "outfile": + options.outFile = setting.value; + break; + case "outdiroption": case "outdir": options.outDir = setting.value; @@ -1159,6 +1216,10 @@ module Harness { options.isolatedModules = setting.value === "true"; break; + case "suppressexcesspropertyerrors": + options.suppressExcessPropertyErrors = setting.value === "true"; + break; + case "suppressimplicitanyindexerrors": options.suppressImplicitAnyIndexErrors = setting.value === "true"; break; @@ -1229,7 +1290,8 @@ module Harness { assert(sourceFile, "Program has no source file with name '" + fileName + "'"); // Is this file going to be emitted separately let sourceFileName: string; - if (ts.isExternalModule(sourceFile) || !options.out) { + let outFile = options.outFile || options.out; + if (ts.isExternalModule(sourceFile) || !outFile) { if (options.outDir) { let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram); sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); @@ -1241,7 +1303,7 @@ module Harness { } else { // Goes to single --out file - sourceFileName = options.out; + sourceFileName = outFile; } let dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; @@ -1273,7 +1335,7 @@ module Harness { errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): "; } - errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()) + Harness.IO.newLine(); }); return errorOutput; @@ -1282,11 +1344,11 @@ module Harness { export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) { diagnostics.sort(ts.compareDiagnostics); let outputLines: string[] = []; - // Count up all the errors we find so we don't miss any - let totalErrorsReported = 0; + // Count up all errors that were found in files other than lib.d.ts so we don't miss any + let totalErrorsReportedInNonLibraryFiles = 0; function outputErrorText(error: ts.Diagnostic) { - let message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine); + let message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()); let errLines = RunnerBase.removeFullPaths(message) .split("\n") @@ -1294,8 +1356,15 @@ module Harness { .filter(s => s.length > 0) .map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s); errLines.forEach(e => outputLines.push(e)); - - totalErrorsReported++; + + // do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics + // if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers) + // then they will be added twice thus triggering 'total errors' assertion with condition + // 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length + + if (!error.file || !isLibraryFile(error.file.fileName)) { + totalErrorsReportedInNonLibraryFiles++; + } } // Report global errors @@ -1380,10 +1449,10 @@ module Harness { }); // Verify we didn't miss any errors in total - assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); + assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); return minimalDiagnosticsToString(diagnostics) + - ts.sys.newLine + ts.sys.newLine + outputLines.join("\r\n"); + Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); } export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { @@ -1524,7 +1593,7 @@ module Harness { "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", - "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", + "includebuiltfile", "suppressexcesspropertyerrors", "suppressimplicitanyindexerrors", "stripinternal", "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", "inlinesources", "emitdecoratormetadata", "experimentaldecorators", "skipdefaultlibcheck", "jsx"]; @@ -1719,7 +1788,7 @@ module Harness { } function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { - let encoded_actual = (new Buffer(actual)).toString("utf8"); + let encoded_actual = Utils.encodeString(actual); if (expected != encoded_actual) { // Overwrite & issue error let errMsg = "The baseline file " + relativeFileName + " has changed"; @@ -1758,11 +1827,11 @@ module Harness { return filePath.indexOf(Harness.libFolder) === 0; } - export function getDefaultLibraryFile(): { unitName: string, content: string } { - let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; + export function getDefaultLibraryFile(io: Harness.IO): { unitName: string, content: string } { + let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts"; return { unitName: libFile, - content: IO.readFile(libFile) + content: io.readFile(libFile) }; } diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index db82a47d362..5a572e220b3 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -93,7 +93,7 @@ module Playback { return run; } - export interface PlaybackSystem extends ts.System, PlaybackControl { } + export interface PlaybackIO extends Harness.IO, PlaybackControl { } function createEmptyLog(): IOLog { return { @@ -223,8 +223,8 @@ module Playback { // console.log("Swallowed write operation during replay: " + name); } - export function wrapSystem(underlying: ts.System): PlaybackSystem { - let wrapper: PlaybackSystem = {}; + export function wrapIO(underlying: Harness.IO): PlaybackIO { + let wrapper: PlaybackIO = {}; initWrapper(wrapper, underlying); wrapper.startReplayFromFile = logFn => { @@ -239,18 +239,24 @@ module Playback { recordLog = undefined; } }; - - Object.defineProperty(wrapper, "args", { - get() { - if (replayLog !== undefined) { - return replayLog.arguments; - } else if (recordLog !== undefined) { - recordLog.arguments = underlying.args; - } - return underlying.args; + + wrapper.args = () => { + if (replayLog !== undefined) { + return replayLog.arguments; + } else if (recordLog !== undefined) { + recordLog.arguments = underlying.args(); } - }); - + return underlying.args(); + } + + wrapper.newLine = () => underlying.newLine(); + wrapper.useCaseSensitiveFileNames = () => underlying.useCaseSensitiveFileNames(); + wrapper.directoryName = (path): string => { throw new Error("NotSupported"); }; + wrapper.createDirectory = path => { throw new Error("NotSupported"); }; + wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); }; + wrapper.deleteFile = path => { throw new Error("NotSupported"); }; + wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); }; + wrapper.log = text => underlying.log(text); wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( (path) => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path: path }), diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 1790956755a..fe4ab8ea8ea 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -62,7 +62,7 @@ class ProjectRunner extends RunnerBase { let testFileText: string = null; try { - testFileText = ts.sys.readFile(testCaseFileName); + testFileText = Harness.IO.readFile(testCaseFileName); } catch (e) { assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message); @@ -98,7 +98,7 @@ class ProjectRunner extends RunnerBase { } function cleanProjectUrl(url: string) { - let diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot)); + let diskProjectPath = ts.normalizeSlashes(Harness.IO.resolvePath(testCase.projectRoot)); let projectRootUrl = "file:///" + diskProjectPath; let normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot); diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot)); @@ -122,7 +122,7 @@ class ProjectRunner extends RunnerBase { } function getCurrentDirectory() { - return ts.sys.resolvePath(testCase.projectRoot); + return Harness.IO.resolvePath(testCase.projectRoot); } function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[], @@ -158,11 +158,12 @@ class ProjectRunner extends RunnerBase { return { declaration: !!testCase.declaration, sourceMap: !!testCase.sourceMap, - out: testCase.out, + outFile: testCase.out, outDir: testCase.outDir, - mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? ts.sys.resolvePath(testCase.mapRoot) : testCase.mapRoot, - sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? ts.sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot, + mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot, + sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot, module: moduleKind, + moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future noResolve: testCase.noResolve, rootDir: testCase.rootDir }; @@ -190,8 +191,8 @@ class ProjectRunner extends RunnerBase { writeFile, getCurrentDirectory, getCanonicalFileName: Harness.Compiler.getCanonicalFileName, - useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, - getNewLine: () => ts.sys.newLine, + useCaseSensitiveFileNames: () => Harness.IO.useCaseSensitiveFileNames(), + getNewLine: () => Harness.IO.newLine(), fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined, readFile: fileName => Harness.IO.readFile(fileName) }; @@ -216,7 +217,7 @@ class ProjectRunner extends RunnerBase { function getSourceFileText(fileName: string): string { let text: string = undefined; try { - text = ts.sys.readFile(ts.isRootedDiskPath(fileName) + text = Harness.IO.readFile(ts.isRootedDiskPath(fileName) ? fileName : ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName)); } @@ -263,14 +264,14 @@ class ProjectRunner extends RunnerBase { // Actual writing of file as in tc.ts function ensureDirectoryStructure(directoryname: string) { if (directoryname) { - if (!ts.sys.directoryExists(directoryname)) { + if (!Harness.IO.directoryExists(directoryname)) { ensureDirectoryStructure(ts.getDirectoryPath(directoryname)); - ts.sys.createDirectory(directoryname); + Harness.IO.createDirectory(directoryname); } } } ensureDirectoryStructure(ts.getDirectoryPath(ts.normalizePath(outputFilePath))); - ts.sys.writeFile(outputFilePath, data, writeByteOrderMark); + Harness.IO.writeFile(outputFilePath, data); outputFiles.push({ emittedFileName: fileName, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark }); } @@ -299,7 +300,7 @@ class ProjectRunner extends RunnerBase { allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName)); } else { - let outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile|| compilerOptions.out) + ".d.ts"; let outputDtsFile = findOutpuDtsFile(outputDtsFileName); if (!ts.contains(allInputFiles, outputDtsFile)) { allInputFiles.unshift(outputDtsFile); @@ -391,7 +392,7 @@ class ProjectRunner extends RunnerBase { Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { try { - return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); + return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); } catch (e) { return undefined; diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 3d97938011c..822fcdebe8c 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -106,6 +106,4 @@ if (runners.length === 0) { // runners.push(new GeneratedFourslashRunner()); } -ts.sys.newLine = "\r\n"; - runTests(runners); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index d8b52ec2e39..a1aaeed3d55 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -4,18 +4,18 @@ /// module RWC { - function runWithIOLog(ioLog: IOLog, fn: () => void) { - let oldSys = ts.sys; + function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) { + let oldIO = Harness.IO; - let wrappedSys = Playback.wrapSystem(ts.sys); - wrappedSys.startReplayFromData(ioLog); - ts.sys = wrappedSys; + let wrappedIO = Playback.wrapIO(oldIO); + wrappedIO.startReplayFromData(ioLog); + Harness.IO = wrappedIO; try { - fn(); + fn(oldIO); } finally { - wrappedSys.endReplay(); - ts.sys = oldSys; + wrappedIO.endReplay(); + Harness.IO = oldIO; } } @@ -32,7 +32,6 @@ module RWC { let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; let currentDirectory: string; let useCustomLibraryFile: boolean; - after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -57,7 +56,7 @@ module RWC { currentDirectory = ioLog.currentDirectory; useCustomLibraryFile = ioLog.useCustomLibraryFile; runWithIOLog(ioLog, () => { - opts = ts.parseCommandLine(ioLog.arguments); + opts = ts.parseCommandLine(ioLog.arguments, fileName => Harness.IO.readFile(fileName)); assert.equal(opts.errors.length, 0); // To provide test coverage of output javascript file, @@ -65,7 +64,7 @@ module RWC { opts.options.noEmitOnError = false; }); - runWithIOLog(ioLog, () => { + runWithIOLog(ioLog, oldIO => { harnessCompiler.reset(); // Load the files @@ -77,7 +76,7 @@ module RWC { let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath; for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. - const resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); + const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path)); let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath)); if (!Harness.isLibraryFile(fileRead.path)) { @@ -97,7 +96,8 @@ module RWC { inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } else { - inputFiles.push(Harness.getDefaultLibraryFile()); + // set the flag to put default library to the beginning of the list + inputFiles.unshift(Harness.getDefaultLibraryFile(oldIO)); } } } @@ -118,13 +118,13 @@ module RWC { }); function getHarnessCompilerInputUnit(fileName: string) { - let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName)); + let unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName)); let content: string = null; try { - content = ts.sys.readFile(unitName); + content = Harness.IO.readFile(unitName); } catch (e) { - content = ts.sys.readFile(fileName); + content = Harness.IO.readFile(fileName); } return { unitName, content }; } @@ -187,7 +187,7 @@ module RWC { } return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + - ts.sys.newLine + ts.sys.newLine + + Harness.IO.newLine() + Harness.IO.newLine() + Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); }, false, baselineOpts); } diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index bffdac3a3e2..7259ff5081c 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -316,22 +316,22 @@ 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 searchValue A string that represents the regular expression. * @param replacer A function that returns the replacement text. */ 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; @@ -1182,3 +1182,2644 @@ 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/src/lib/dom.es6.d.ts b/src/lib/dom.es6.d.ts index 8702201bb9e..e83b8531011 100644 --- a/src/lib/dom.es6.d.ts +++ b/src/lib/dom.es6.d.ts @@ -8,4 +8,4 @@ interface NodeList { interface NodeListOf { [Symbol.iterator](): IterableIterator -} \ No newline at end of file +} diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 8eec72f1a4c..90075a290a4 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -2459,7 +2459,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. @@ -2916,6 +2916,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3030,7 +3031,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 { @@ -3903,7 +3904,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -6865,7 +6865,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; } @@ -6986,7 +6986,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; @@ -7016,11 +7016,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; @@ -7703,7 +7706,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -8445,7 +8448,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -12169,7 +12172,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; @@ -12439,7 +12442,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; @@ -12595,7 +12598,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; @@ -12617,12 +12620,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -12952,4 +12975,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; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 10358a5e74d..c07d047b58e 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -251,11 +251,6 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; @@ -425,6 +420,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 @@ -827,440 +857,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. @@ -1268,289 +893,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. @@ -1558,289 +925,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. @@ -1848,289 +961,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. @@ -2138,289 +997,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. @@ -2428,289 +1029,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. @@ -2718,289 +1061,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. @@ -3008,289 +1093,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. @@ -3298,289 +1125,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. @@ -3588,9 +1157,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; @@ -3615,9 +1183,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; @@ -3718,20 +1286,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/src/lib/extensions.d.ts b/src/lib/extensions.d.ts deleted file mode 100644 index 8c67c7e826f..00000000000 --- a/src/lib/extensions.d.ts +++ /dev/null @@ -1,2305 +0,0 @@ - -///////////////////////////// -/// 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; \ No newline at end of file diff --git a/src/lib/intl.d.ts b/src/lib/intl.d.ts index 57df70672d4..b5291306b87 100644 --- a/src/lib/intl.d.ts +++ b/src/lib/intl.d.ts @@ -88,6 +88,7 @@ declare module Intl { timeZoneName?: string; formatMatcher?: string; hour12?: boolean; + timeZone?: string; } interface ResolvedDateTimeFormatOptions { @@ -157,17 +158,44 @@ interface Number { interface Date { /** - * Converts a date to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + /** * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index db8b02f34d7..9353047e9c6 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -3,10 +3,28 @@ /// 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; @@ -60,6 +78,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; @@ -210,7 +243,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 { @@ -281,7 +314,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; } @@ -402,7 +435,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; @@ -432,11 +465,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; @@ -460,6 +496,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; @@ -496,6 +555,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; @@ -516,7 +587,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -533,6 +604,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; @@ -542,7 +640,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface WebSocket extends EventTarget { @@ -620,7 +718,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; @@ -642,6 +740,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; @@ -661,7 +768,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; @@ -702,7 +809,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; @@ -788,23 +895,37 @@ 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; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -820,11 +941,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; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 14bb7712ce7..76bc586b8bb 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -224,6 +224,14 @@ namespace ts.server { this.roots.push(info); } } + + removeRoot(info: ScriptInfo) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (scriptInfo) { + this.filenameToScript[info.fileName] = undefined; + this.roots = copyListRemovingItem(info, this.roots); + } + } saveTo(filename: string, tmpfilename: string) { var script = this.getScriptInfo(filename); @@ -345,6 +353,7 @@ namespace ts.server { export class Project { compilerService: CompilerService; projectFilename: string; + projectFileWatcher: FileWatcher; program: ts.Program; filenameToSourceFile: ts.Map = {}; updateGraphSeq = 0; @@ -352,7 +361,7 @@ namespace ts.server { openRefCount = 0; constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) { - this.compilerService = new CompilerService(this,projectOptions && projectOptions.compilerOptions); + this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } addOpenRef() { @@ -423,6 +432,12 @@ namespace ts.server { info.defaultProject = this; this.compilerService.host.addRoot(info); } + + // remove a root file from project + removeRoot(info: ScriptInfo) { + info.defaultProject = undefined; + this.compilerService.host.removeRoot(info); + } filesToString() { var strBuilder = ""; @@ -517,6 +532,12 @@ namespace ts.server { } } + watchedProjectConfigFileChanged(project: Project) { + this.log("Config File Changed: " + project.projectFilename); + this.updateConfiguredProject(project); + this.updateProjectStructure(); + } + log(msg: string, type = "Err") { this.psLogger.msg(msg, type); } @@ -594,16 +615,29 @@ namespace ts.server { this.configuredProjects = configuredProjects; } + removeConfiguredProject(project: Project) { + project.projectFileWatcher.close(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + + let fileNames = project.getFileNames(); + for (let fileName of fileNames) { + let info = this.getScriptInfo(fileName); + if (info.defaultProject == project) { + info.defaultProject = undefined; + } + } + } + setConfiguredProjectRoot(info: ScriptInfo) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - let configuredProject = this.configuredProjects[i]; - if (configuredProject.isRoot(info)) { - info.defaultProject = configuredProject; - configuredProject.addOpenRef(); - return true; - } - } - return false; + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + let configuredProject = this.configuredProjects[i]; + if (configuredProject.isRoot(info)) { + info.defaultProject = configuredProject; + configuredProject.addOpenRef(); + return true; + } + } + return false; } addOpenFile(info: ScriptInfo) { @@ -647,7 +681,6 @@ namespace ts.server { /** * Remove this file from the set of open, non-configured files. * @param info The file that has been closed or newly configured - * @param openedByConfig True if info has become a root of a configured project */ closeOpenFile(info: ScriptInfo) { var openFileRoots: ScriptInfo[] = []; @@ -736,18 +769,42 @@ namespace ts.server { return referencingProjects; } + reloadProjects() { + // First check if there is new tsconfig file added for inferred project roots + for (let info of this.openFileRoots) { + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.updateProjectStructure(); + } + + /** + * This function is to update the project structure for every projects. + * It is called on the premise that all the configured projects are + * up to date. + */ updateProjectStructure() { this.log("updating project structure from ...", "Info"); this.printProjects(); + let unattachedOpenFiles: ScriptInfo[] = []; + let openFileRootsConfigured: ScriptInfo[] = []; + for (let info of this.openFileRootsConfigured) { + let project = info.defaultProject; + if (!project || !(project.getSourceFile(info))) { + info.defaultProject = undefined; + unattachedOpenFiles.push(info); + } + else { + openFileRootsConfigured.push(info); + } + } + this.openFileRootsConfigured = openFileRootsConfigured; + // First loop through all open files that are referenced by projects but are not // project roots. For each referenced file, see if the default project still // references that file. If so, then just keep the file in the referenced list. // If not, add the file to an unattached list, to be rechecked later. - var openFilesReferenced: ScriptInfo[] = []; - var unattachedOpenFiles: ScriptInfo[] = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var referencedFile = this.openFilesReferenced[i]; referencedFile.defaultProject.updateGraph(); @@ -857,32 +914,40 @@ namespace ts.server { * Open file whose contents is managed by the client * @param filename is absolute pathname */ - openClientFile(fileName: string) { - var searchPath = ts.normalizePath(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 && (!this.configProjectIsActive(configFileName))) { - 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); - } - } + this.openOrUpdateConfiguredProjectForFile(fileName); var info = this.openFile(fileName, true); this.addOpenFile(info); this.printProjects(); return info; } + openOrUpdateConfiguredProjectForFile(fileName: string) { + let searchPath = ts.normalizePath(getDirectoryPath(fileName)); + this.log("Search path: " + searchPath, "Info"); + let configFileName = this.findConfigFile(searchPath); + if (configFileName) { + this.log("Config file name: " + configFileName, "Info"); + let 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.updateConfiguredProject(project); + } + } + else { + this.log("No config files found."); + } + } + /** * Close file whose contents is managed by the client * @param filename is absolute pathname @@ -935,7 +1000,7 @@ namespace ts.server { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { var project = this.configuredProjects[i]; project.updateGraph(); - this.psLogger.info("Project (configured) " + (i+this.inferredProjects.length).toString()); + this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString()); this.psLogger.info(project.filesToString()); this.psLogger.info("-----------------------------------------------"); } @@ -959,49 +1024,113 @@ namespace ts.server { } configProjectIsActive(fileName: string) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == fileName) { - return true; - } - } - return false; + return this.findConfiguredProjectByConfigFile(fileName) === undefined; } - openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { + findConfiguredProjectByConfigFile(configFileName: string) { + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + if (this.configuredProjects[i].projectFilename == configFileName) { + return this.configuredProjects[i]; + } + } + return undefined; + } + + configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, error?: ProjectOpenResult } { configFilename = ts.normalizePath(configFilename); // file references will be relative to dirPath (or absolute) var dirPath = ts.getDirectoryPath(configFilename); var contents = this.host.readFile(configFilename) var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = 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: 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 }; + } + } + + } + + openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { + let { succeeded, projectOptions, error } = this.configFileToProjectOptions(configFilename); + if (!succeeded) { + return error; + } + else { + let proj = this.createProject(configFilename, projectOptions); + for (let i = 0, len = projectOptions.files.length; i < len; i++) { + let rootFilename = projectOptions.files[i]; + if (this.host.fileExists(rootFilename)) { + let info = this.openFile(rootFilename, /*openedByClient*/ 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, _ => this.watchedProjectConfigFileChanged(proj)); + return { success: true, project: proj }; + } + } + + updateConfiguredProject(project: Project) { + if (!this.host.fileExists(project.projectFilename)) { + this.log("Config file deleted"); + this.removeConfiguredProject(project); + } + else { + let { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename); + if (!succeeded) { + return error; } else { - return { errorMsg: "no files found" }; + let oldFileNames = project.compilerService.host.roots.map(info => info.fileName); + let newFileNames = projectOptions.files; + let fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0); + let fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0); + + for (let fileName of fileNamesToRemove) { + let info = this.getScriptInfo(fileName); + project.removeRoot(info); + } + + for (let fileName of fileNamesToAdd) { + let info = this.getScriptInfo(fileName); + if (!info) { + info = this.openFile(fileName, false); + } + else { + // if the root file was opened by client, it would belong to either + // openFileRoots or openFileReferenced. + if (info.isOpen) { + if (this.openFileRoots.indexOf(info) >= 0) { + 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(); } } } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 2d694025c84..ce918abda3c 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -31,6 +31,12 @@ declare namespace ts.server.protocol { */ arguments?: any; } + + /** + * Request to reload the project structure for all the opened files + */ + export interface ReloadProjectsRequest extends Message { + } /** * Server-initiated event message diff --git a/src/server/session.ts b/src/server/session.ts index 108cf4726dc..da044e7b4c6 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -100,6 +100,7 @@ namespace ts.server { export const SignatureHelp = "signatureHelp"; export const TypeDefinition = "typeDefinition"; export const ProjectInfo = "projectInfo"; + export const ReloadProjects = "reloadProjects"; export const Unknown = "unknown"; } @@ -226,6 +227,10 @@ namespace ts.server { this.syntacticCheck(file, project); this.semanticCheck(file, project); } + + private reloadProjects() { + this.projectService.reloadProjects(); + } private updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) { setTimeout(() => { @@ -1033,6 +1038,10 @@ namespace ts.server { var { file, needFileNameList } = request.arguments; return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true}; }, + [CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => { + this.reloadProjects(); + return {responseRequired: false}; + } }; public addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) { if (this.handlers[command]) { diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index d4e096974b7..f609edb0501 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -213,6 +213,26 @@ namespace ts.formatting { public NoSpaceBetweenYieldKeywordAndStar: Rule; public SpaceBetweenYieldOrYieldStarAndOperand: Rule; + // Async-await + public SpaceBetweenAsyncAndFunctionKeyword: Rule; + public NoSpaceBetweenAsyncAndFunctionKeyword: Rule; + public SpaceAfterAwaitKeyword: Rule; + public NoSpaceAfterAwaitKeyword: Rule; + + // Type alias declaration + public SpaceAfterTypeKeyword: Rule; + public NoSpaceAfterTypeKeyword: Rule; + + // Tagged template string + public SpaceBetweenTagAndTemplateString: Rule; + public NoSpaceBetweenTagAndTemplateString: Rule; + + // Union type + public SpaceBeforeBar: Rule; + public NoSpaceBeforeBar: Rule; + public SpaceAfterBar: Rule; + public NoSpaceAfterBar: Rule; + constructor() { /// /// Common Rules @@ -360,6 +380,27 @@ namespace ts.formatting { this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete)); this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // Type alias declaration + this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // template string + this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // union type + this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -386,6 +427,11 @@ namespace ts.formatting { this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 30211e0a910..8f3a5715abe 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -408,6 +408,7 @@ namespace ts.formatting { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: @@ -431,6 +432,16 @@ namespace ts.formatting { case SyntaxKind.JsxElement: case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxExpression: + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.Parameter: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.UnionType: + case SyntaxKind.ParenthesizedType: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.AwaitExpression: return true; } return false; @@ -450,8 +461,6 @@ namespace ts.formatting { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.CallSignature: case SyntaxKind.ArrowFunction: case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: diff --git a/src/services/services.ts b/src/services/services.ts index eb275120b89..752fb93cd00 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -132,6 +132,46 @@ namespace ts { let scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); let emptyArray: any[] = []; + + const jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + let jsDocCompletionEntries: CompletionEntry[]; function createNode(kind: SyntaxKind, pos: number, end: number, flags: NodeFlags, parent?: Node): NodeObject { let node = new (getNodeConstructor(kind))(); @@ -1842,9 +1882,8 @@ namespace ts { getCanonicalFileName: fileName => fileName, getCurrentDirectory: () => "", getNewLine: () => newLine, - // these two methods should never be called in transpile scenarios since 'noResolve' is set to 'true' - fileExists: (fileName): boolean => { throw new Error("Should never be called."); }, - readFile: (fileName): string => { throw new Error("Should never be called."); } + fileExists: (fileName): boolean => fileName === inputFileName, + readFile: (fileName): string => "" }; let program = createProgram([inputFileName], options, compilerHost); @@ -2972,6 +3011,8 @@ namespace ts { let sourceFile = getValidSourceFile(fileName); let isJavaScriptFile = isJavaScript(fileName); + let isJsDocTagName = false; + let start = new Date().getTime(); let currentToken = getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -2982,8 +3023,44 @@ namespace ts { log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { + isJsDocTagName = true; + } + + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + let insideJsDocTagExpression = false; + let tag = getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + + switch (tag.kind) { + case SyntaxKind.JSDocTypeTag: + case SyntaxKind.JSDocParameterTag: + case SyntaxKind.JSDocReturnTag: + let tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName }; + } + + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); @@ -3069,7 +3146,7 @@ namespace ts { log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list @@ -3512,10 +3589,11 @@ namespace ts { containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | isFunction(containingNodeKind) || containingNodeKind === SyntaxKind.ClassDeclaration || // class A { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0", + } + })); + } + function createCompletionEntry(symbol: Symbol, location: Node): CompletionEntry { // 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 @@ -4088,6 +4183,7 @@ namespace ts { displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); @@ -4128,16 +4224,29 @@ namespace ts { } else { // Method/function type parameter - let signatureDeclaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; - let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) { - displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + let container = getContainingFunction(location); + if (container) { + let signatureDeclaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; + let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) { + displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + displayParts.push(spacePart()); + } + else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; + displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); } } if (symbolFlags & SymbolFlags.EnumMember) { @@ -4371,10 +4480,19 @@ namespace ts { // and in either case the symbol has a construct signature definition, i.e. class if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) { if (symbol.flags & SymbolFlags.Class) { - let classDeclaration = symbol.getDeclarations()[0]; - Debug.assert(classDeclaration && classDeclaration.kind === SyntaxKind.ClassDeclaration); + // Find the first class-like declaration and try to get the construct signature. + for (let declaration of symbol.getDeclarations()) { + if (isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, + symbolKind, + symbolName, + containerName, + result); + } + } - return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; @@ -5767,6 +5885,7 @@ namespace ts { result.push(getReferenceEntryFromNode(node)); } break; + case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. diff --git a/src/services/shims.ts b/src/services/shims.ts index e6ec71f368b..307062cebd8 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1097,4 +1097,4 @@ module TypeScript.Services { } /* @internal */ -let toolsVersion = "1.5"; +const toolsVersion = "1.6"; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 04bfd04057c..d5ad93260cd 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -469,6 +469,39 @@ namespace ts { } } + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + export function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag { + let node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case SyntaxKind.VarKeyword: + case SyntaxKind.LetKeyword: + case SyntaxKind.ConstKeyword: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + + if (node) { + let jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (let tag of jsDocComment.tags) { + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + + return undefined; + } + function nodeHasTokens(n: Node): boolean { // 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. @@ -640,7 +673,6 @@ namespace ts { else if (flags & SymbolFlags.TypeAlias) { return SymbolDisplayPartKind.aliasName; } else if (flags & SymbolFlags.Alias) { return SymbolDisplayPartKind.aliasName; } - return SymbolDisplayPartKind.text; } } diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols index 208646dc101..2c5e611de68 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols +++ b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols @@ -9,9 +9,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe let blah = arguments[Symbol.iterator]; >blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7)) >arguments : Symbol(arguments) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) let result = []; >result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7)) diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 9b05aff5ac6..20f36e5c459 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -294,8 +294,8 @@ module EmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -313,8 +313,8 @@ module EmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -332,8 +332,8 @@ module EmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -639,7 +639,7 @@ module NonEmptyTypes { >x : number >y : base >base : base ->[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : ({ x: number; y: derived; } | { x: number; y: base; })[] +>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number >7 : number @@ -658,7 +658,7 @@ module NonEmptyTypes { >x : boolean >y : base >base : base ->[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: boolean; y: derived; } | { x: boolean; y: base; })[] +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[] >{ x: true, y: new derived() } : { x: boolean; y: derived; } >x : boolean >true : boolean @@ -697,8 +697,8 @@ module NonEmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -716,8 +716,8 @@ module NonEmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -735,8 +735,8 @@ module NonEmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -769,29 +769,29 @@ module NonEmptyTypes { >base2 : typeof base2 var b1 = [baseObj, base2Obj, ifaceObj]; ->b1 : (base | base2 | iface)[] ->[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[] +>b1 : iface[] +>[baseObj, base2Obj, ifaceObj] : iface[] >baseObj : base >base2Obj : base2 >ifaceObj : iface var b2 = [base2Obj, baseObj, ifaceObj]; ->b2 : (base2 | base | iface)[] ->[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[] +>b2 : iface[] +>[base2Obj, baseObj, ifaceObj] : iface[] >base2Obj : base2 >baseObj : base >ifaceObj : iface var b3 = [baseObj, ifaceObj, base2Obj]; ->b3 : (base | iface | base2)[] ->[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[] +>b3 : iface[] +>[baseObj, ifaceObj, base2Obj] : iface[] >baseObj : base >ifaceObj : iface >base2Obj : base2 var b4 = [ifaceObj, baseObj, base2Obj]; ->b4 : (iface | base | base2)[] ->[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[] +>b4 : iface[] +>[ifaceObj, baseObj, base2Obj] : iface[] >ifaceObj : iface >baseObj : base >base2Obj : base2 diff --git a/tests/baselines/reference/arrayCast.errors.txt b/tests/baselines/reference/arrayCast.errors.txt index 82b4b856a97..815813ea727 100644 --- a/tests/baselines/reference/arrayCast.errors.txt +++ b/tests/baselines/reference/arrayCast.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. +tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. Type '{ foo: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. @@ -7,7 +7,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin // Should fail. Even though the array is contextually typed with { id: number }[], it still // has type { foo: string }[], which is not assignable to { id: number }[]. <{ id: number; }[]>[{ foo: "s" }]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. !!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'. !!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. diff --git a/tests/baselines/reference/arrayLiteralTypeInference.errors.txt b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt index 105375f2e74..a2c4597127f 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.errors.txt +++ b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. +tests/cases/compiler/arrayLiteralTypeInference.ts(14,14): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. -tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/arrayLiteralTypeInference.ts(31,18): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. @@ -22,12 +22,12 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ } var x1: Action[] = [ - ~~ + { id: 2, trueness: false }, + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. !!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. !!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. !!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. - { id: 2, trueness: false }, { id: 3, name: "three" } ] @@ -43,13 +43,13 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ ] var z1: { id: number }[] = - ~~ + [ + { id: 2, trueness: false }, + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. - [ - { id: 2, trueness: false }, { id: 3, name: "three" } ] diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index 5b5a1be6b8a..1bbb6c41e8a 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[] >c : { x: number; a?: number; } var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] ->ds : (((x: Object) => number) | ((x: string) => number))[] ->[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[] +>ds : ((x: Object) => number)[] +>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[] >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object @@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] >2 : number var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] ->es : (((x: string) => number) | ((x: Object) => number))[] ->[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[] +>es : ((x: string) => number)[] +>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[] >(x: string) => 2 : (x: string) => number >x : string >2 : number diff --git a/tests/baselines/reference/arrayLiterals.errors.txt b/tests/baselines/reference/arrayLiterals.errors.txt index fd882804b8a..f5fe71b79a6 100644 --- a/tests/baselines/reference/arrayLiterals.errors.txt +++ b/tests/baselines/reference/arrayLiterals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,77): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. Index signatures are incompatible. Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'. @@ -30,7 +30,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; - ~~~~~~~~ + ~~~~~ !!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index ca3e20c022b..fd31800e840 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index b7224fe91c4..9cdbe0a0a61 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -77,8 +77,8 @@ var myDerivedList: DerivedList; >DerivedList : DerivedList var as = [list, myDerivedList]; // List[] ->as : (List | DerivedList)[] ->[list, myDerivedList] : (List | DerivedList)[] +>as : List[] +>[list, myDerivedList] : List[] >list : List >myDerivedList : DerivedList diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt b/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt deleted file mode 100644 index 499d6bca387..00000000000 --- a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ==== - // valid uses of arrays of function types - - var x = [() => 1, () => { }]; - var r2 = x[0](); - - class C { - foo: string; - } - var y = [C, C]; - var r3 = new y[0](); - - var a: { (x: number): number; (x: string): string; }; - var b: { (x: number): number; (x: string): string; }; - var c: { (x: number): number; (x: any): any; }; - var z = [a, b, c]; - var r4 = z[0]; - var r5 = r4(''); // any not string - ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. - var r5b = r4(1); - - var a2: { (x: T): number; (x: string): string;}; - var b2: { (x: T): number; (x: string): string; }; - var c2: { (x: number): number; (x: T): any; }; - - var z2 = [a2, b2, c2]; - var r6 = z2[0]; - var r7 = r6(''); // any not string - ~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.symbols b/tests/baselines/reference/arrayOfFunctionTypes3.symbols new file mode 100644 index 00000000000..d26effeb5b7 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.symbols @@ -0,0 +1,93 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +var r2 = x[0](); +>r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +class C { +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + + foo: string; +>foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9)) +} +var y = [C, C]; +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + +var r3 = new y[0](); +>r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3)) +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) + +var a: { (x: number): number; (x: string): string; }; +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31)) + +var b: { (x: number): number; (x: string): string; }; +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31)) + +var c: { (x: number): number; (x: any): any; }; +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31)) + +var z = [a, b, c]; +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) + +var r4 = z[0]; +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) + +var r5 = r4(''); // any not string +>r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var r5b = r4(1); +>r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var a2: { (x: T): number; (x: string): string;}; +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30)) + +var b2: { (x: T): number; (x: string): string; }; +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30)) + +var c2: { (x: number): number; (x: T): any; }; +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) + +var z2 = [a2, b2, c2]; +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) + +var r6 = z2[0]; +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) + +var r7 = r6(''); // any not string +>r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3)) +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) + diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.types b/tests/baselines/reference/arrayOfFunctionTypes3.types new file mode 100644 index 00000000000..0ed92991ed0 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : (() => void)[] +>[() => 1, () => { }] : (() => void)[] +>() => 1 : () => number +>1 : number +>() => { } : () => void + +var r2 = x[0](); +>r2 : void +>x[0]() : void +>x[0] : () => void +>x : (() => void)[] +>0 : number + +class C { +>C : C + + foo: string; +>foo : string +} +var y = [C, C]; +>y : typeof C[] +>[C, C] : typeof C[] +>C : typeof C +>C : typeof C + +var r3 = new y[0](); +>r3 : C +>new y[0]() : C +>y[0] : typeof C +>y : typeof C[] +>0 : number + +var a: { (x: number): number; (x: string): string; }; +>a : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var b: { (x: number): number; (x: string): string; }; +>b : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var c: { (x: number): number; (x: any): any; }; +>c : { (x: number): number; (x: any): any; } +>x : number +>x : any + +var z = [a, b, c]; +>z : { (x: number): number; (x: any): any; }[] +>[a, b, c] : { (x: number): number; (x: any): any; }[] +>a : { (x: number): number; (x: string): string; } +>b : { (x: number): number; (x: string): string; } +>c : { (x: number): number; (x: any): any; } + +var r4 = z[0]; +>r4 : { (x: number): number; (x: any): any; } +>z[0] : { (x: number): number; (x: any): any; } +>z : { (x: number): number; (x: any): any; }[] +>0 : number + +var r5 = r4(''); // any not string +>r5 : any +>r4('') : any +>r4 : { (x: number): number; (x: any): any; } +>'' : string + +var r5b = r4(1); +>r5b : number +>r4(1) : number +>r4 : { (x: number): number; (x: any): any; } +>1 : number + +var a2: { (x: T): number; (x: string): string;}; +>a2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var b2: { (x: T): number; (x: string): string; }; +>b2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var c2: { (x: number): number; (x: T): any; }; +>c2 : { (x: number): number; (x: T): any; } +>x : number +>T : T +>x : T +>T : T + +var z2 = [a2, b2, c2]; +>z2 : { (x: number): number; (x: T): any; }[] +>[a2, b2, c2] : { (x: number): number; (x: T): any; }[] +>a2 : { (x: T): number; (x: string): string; } +>b2 : { (x: T): number; (x: string): string; } +>c2 : { (x: number): number; (x: T): any; } + +var r6 = z2[0]; +>r6 : { (x: number): number; (x: T): any; } +>z2[0] : { (x: number): number; (x: T): any; } +>z2 : { (x: number): number; (x: T): any; }[] +>0 : number + +var r7 = r6(''); // any not string +>r7 : any +>r6('') : any +>r6 : { (x: number): number; (x: T): any; } +>'' : string + diff --git a/tests/baselines/reference/assignmentCompatBug2.errors.txt b/tests/baselines/reference/assignmentCompatBug2.errors.txt index 53e12635888..29ba96e6586 100644 --- a/tests/baselines/reference/assignmentCompatBug2.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(1,27): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(3,8): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(5,13): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'. @@ -14,17 +14,17 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: ==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ==== var b2: { b: number;} = { a: 0 }; // error - ~~ + ~~~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = { a: 0 }; // error - ~~ + ~~~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = {b: 0, a: 0 }; - ~~ + ~~~~ !!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. diff --git a/tests/baselines/reference/assignmentCompatBug5.errors.txt b/tests/baselines/reference/assignmentCompatBug5.errors.txt index 790848babf4..1b5e3d80259 100644 --- a/tests/baselines/reference/assignmentCompatBug5.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. +tests/cases/compiler/assignmentCompatBug5.ts(2,8): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'. Type 'string' is not assignable to type 'number'. @@ -12,7 +12,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ ==== tests/cases/compiler/assignmentCompatBug5.ts (4 errors) ==== function foo1(x: { a: number; }) { } foo1({ b: 5 }); - ~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. !!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index c6887d375cf..0da7c4433b3 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) }; diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols index 864173da3a6..6f492b07d1b 100644 --- a/tests/baselines/reference/asyncAwait_es6.symbols +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -2,16 +2,16 @@ type MyPromise = Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) declare var MyPromise: typeof Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare var p: Promise; >p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare var mp: MyPromise; >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) @@ -22,7 +22,7 @@ async function f0() { } async function f1(): Promise { } >f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function f3(): MyPromise { } >f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) @@ -33,7 +33,7 @@ let f4 = async function() { } let f5 = async function(): Promise { } >f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) let f6 = async function(): MyPromise { } >f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) @@ -44,7 +44,7 @@ let f7 = async () => { }; let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) @@ -60,7 +60,7 @@ let f11 = async () => mp; let f12 = async (): Promise => mp; >f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) let f13 = async (): MyPromise => p; @@ -76,7 +76,7 @@ let o = { async m2(): Promise { }, >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) @@ -92,7 +92,7 @@ class C { async m2(): Promise { } >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30)) @@ -103,7 +103,7 @@ class C { static async m5(): Promise { } >m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) static async m6(): MyPromise { } >m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index 1defbec98dc..f7574402c80 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index f1368ff00de..97dc419ba47 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index 75b5a1edd56..35e4394c82d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index f978a3dc37e..b91d8bf9492 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p || a; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index 1cdc4ce24fd..60127a06b90 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p && a; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index b46c79975ef..83f006bc285 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,11 +4,11 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p + a; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index 19e132e0973..38e9ccfe608 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p, a; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index 623cbe5c396..161d697b75b 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var o: { a: boolean; }; diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index 279f3939eef..8c6494d34af 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index 4c9856d5e11..db8cff67f01 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index ebd3c283421..e2b0e8a9137 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index 2377bb7fa62..75067422152 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = (await pfn)(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index f95590ca67e..d9c9cb9ed9a 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = o.fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index e059d6f5086..ee9779e68e8 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = o.fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index 9f9ab9623e8..51ce2db20a2 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = o.fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index 085eb99a9d4..be3a841cce1 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = (await po).fn(a, a, a); diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 933d46cc802..1191004a32b 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -46,8 +46,8 @@ var r = true ? 1 : 2; >2 : number var r3 = true ? 1 : {}; ->r3 : number | {} ->true ? 1 : {} : number | {} +>r3 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -67,8 +67,8 @@ var r5 = true ? b : a; // typeof b >a : { x: number; y?: number; } var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void ->r6 : ((x: number) => void) | ((x: Object) => void) ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>r6 : (x: number) => void +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >r7 : (x: Object) => void >x : Object >Object : Object ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >Object : Object var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void ->r8 : ((x: Object) => void) | ((x: number) => void) ->true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void) +>r8 : (x: Object) => void +>true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void >true : boolean >(x: Object) => { } : (x: Object) => void >x : Object @@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu >derived2 : Derived2 var r11 = true ? base : derived2; ->r11 : Base | Derived2 ->true ? base : derived2 : Base | Derived2 +>r11 : Base +>true ? base : derived2 : Base >true : boolean >base : Base >derived2 : Derived2 diff --git a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types index 4c47753a90d..df40291b0e5 100644 --- a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types +++ b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types @@ -27,43 +27,43 @@ var z: Z; // All these arrays should be X[] var b1 = [x, y, z]; ->b1 : (X | Y | Z)[] ->[x, y, z] : (X | Y | Z)[] +>b1 : X[] +>[x, y, z] : X[] >x : X >y : Y >z : Z var b2 = [x, z, y]; ->b2 : (X | Z | Y)[] ->[x, z, y] : (X | Z | Y)[] +>b2 : X[] +>[x, z, y] : X[] >x : X >z : Z >y : Y var b3 = [y, x, z]; ->b3 : (Y | X | Z)[] ->[y, x, z] : (Y | X | Z)[] +>b3 : X[] +>[y, x, z] : X[] >y : Y >x : X >z : Z var b4 = [y, z, x]; ->b4 : (Y | Z | X)[] ->[y, z, x] : (Y | Z | X)[] +>b4 : X[] +>[y, z, x] : X[] >y : Y >z : Z >x : X var b5 = [z, x, y]; ->b5 : (Z | X | Y)[] ->[z, x, y] : (Z | X | Y)[] +>b5 : X[] +>[z, x, y] : X[] >z : Z >x : X >y : Y var b6 = [z, y, x]; ->b6 : (Z | Y | X)[] ->[z, y, x] : (Z | Y | X)[] +>b6 : X[] +>[z, y, x] : X[] >z : Z >y : Y >x : X diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 0e236821020..8e84f48948f 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1368, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 4009, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/commonjsSafeImport.js b/tests/baselines/reference/commonjsSafeImport.js new file mode 100644 index 00000000000..a0ef81cc277 --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/commonjsSafeImport.ts] //// + +//// [10_lib.ts] + +export function Foo() {} + +//// [main.ts] +import { Foo } from './10_lib'; + +Foo(); + + +//// [10_lib.js] +function Foo() { } +exports.Foo = Foo; +//// [main.js] +var _10_lib_1 = require('./10_lib'); +_10_lib_1.Foo(); + + +//// [10_lib.d.ts] +export declare function Foo(): void; +//// [main.d.ts] diff --git a/tests/baselines/reference/commonjsSafeImport.symbols b/tests/baselines/reference/commonjsSafeImport.symbols new file mode 100644 index 00000000000..45e247b46a0 --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/10_lib.ts === + +export function Foo() {} +>Foo : Symbol(Foo, Decl(10_lib.ts, 0, 0)) + +=== tests/cases/compiler/main.ts === +import { Foo } from './10_lib'; +>Foo : Symbol(Foo, Decl(main.ts, 0, 8)) + +Foo(); +>Foo : Symbol(Foo, Decl(main.ts, 0, 8)) + diff --git a/tests/baselines/reference/commonjsSafeImport.types b/tests/baselines/reference/commonjsSafeImport.types new file mode 100644 index 00000000000..5a4dded5b1f --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/10_lib.ts === + +export function Foo() {} +>Foo : () => void + +=== tests/cases/compiler/main.ts === +import { Foo } from './10_lib'; +>Foo : () => void + +Foo(); +>Foo() : void +>Foo : () => void + diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index d5530f98fe8..026c8f42272 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -31,21 +31,21 @@ var b: B; //Cond ? Expr1 : Expr2, Expr1 is supertype //Be Not contextually typed true ? x : a; ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A var result1 = true ? x : a; ->result1 : X | A ->true ? x : a : X | A +>result1 : X +>true ? x : a : X >true : boolean >x : X >a : A //Expr1 and Expr2 are literals true ? {} : 1; ->true ? {} : 1 : {} | number +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -63,8 +63,8 @@ true ? { a: 1 } : { a: 2, b: 'string' }; >'string' : string var result2 = true ? {} : 1; ->result2 : {} | number ->true ? {} : 1 : {} | number +>result2 : {} +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' }; var resultIsX1: X = true ? x : a; >resultIsX1 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; >result4 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number) +>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any >true : boolean >(m) => m.propertyX : (m: A) => any >m : A @@ -111,21 +111,21 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; //Cond ? Expr1 : Expr2, Expr2 is supertype //Be Not contextually typed true ? a : x; ->true ? a : x : A | X +>true ? a : x : X >true : boolean >a : A >x : X var result5 = true ? a : x; ->result5 : A | X ->true ? a : x : A | X +>result5 : X +>true ? a : x : X >true : boolean >a : A >x : X //Expr1 and Expr2 are literals true ? 1 : {}; ->true ? 1 : {} : number | {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -143,8 +143,8 @@ true ? { a: 2, b: 'string' } : { a: 1 }; >1 : number var result6 = true ? 1 : {}; ->result6 : number | {} ->true ? 1 : {} : number | {} +>result6 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 }; var resultIsX2: X = true ? x : a; >resultIsX2 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; >result8 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any) +>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any >true : boolean >(m) => m.propertyA : (m: A) => number >m : A diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index 4236544defa..586652d41eb 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'. tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'. -tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. +tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal. @@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member // forward reference to the element of the same enum X = Y, ~ -!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. // forward reference to the element of the same enum Y = E1.Z, ~~~~ diff --git a/tests/baselines/reference/contextualTyping12.errors.txt b/tests/baselines/reference/contextualTyping12.errors.txt index 8b079ecc5e0..22ed6ad931e 100644 --- a/tests/baselines/reference/contextualTyping12.errors.txt +++ b/tests/baselines/reference/contextualTyping12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping12.ts(1,57): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: num ==== tests/cases/compiler/contextualTyping12.ts (1 errors) ==== class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTyping17.errors.txt b/tests/baselines/reference/contextualTyping17.errors.txt index 24c428db58b..b6375c9c9c9 100644 --- a/tests/baselines/reference/contextualTyping17.errors.txt +++ b/tests/baselines/reference/contextualTyping17.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping17.ts(1,47): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping17.ts (1 errors) ==== var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"}; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping2.errors.txt b/tests/baselines/reference/contextualTyping2.errors.txt index 2665204b167..1daa4a2a71f 100644 --- a/tests/baselines/reference/contextualTyping2.errors.txt +++ b/tests/baselines/reference/contextualTyping2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping2.ts(1,32): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping2.ts (1 errors) ==== var foo: {id:number;} = {id:4, name:"foo"}; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping20.errors.txt b/tests/baselines/reference/contextualTyping20.errors.txt index d723dcd1d1b..a9112f1db84 100644 --- a/tests/baselines/reference/contextualTyping20.errors.txt +++ b/tests/baselines/reference/contextualTyping20.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping20.ts(1,58): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: num ==== tests/cases/compiler/contextualTyping20.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}]; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTyping4.errors.txt b/tests/baselines/reference/contextualTyping4.errors.txt index 48eb2c406f0..c472e7ccb18 100644 --- a/tests/baselines/reference/contextualTyping4.errors.txt +++ b/tests/baselines/reference/contextualTyping4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping4.ts(1,46): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping4.ts (1 errors) ==== class foo { public bar:{id:number;} = {id:5, name:"foo"}; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping9.errors.txt b/tests/baselines/reference/contextualTyping9.errors.txt index f959d1e2e69..4a12574fa21 100644 --- a/tests/baselines/reference/contextualTyping9.errors.txt +++ b/tests/baselines/reference/contextualTyping9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping9.ts(1,42): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: numbe ==== tests/cases/compiler/contextualTyping9.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.types b/tests/baselines/reference/contextualTypingArrayOfLambdas.types index 0bb61604336..d3e5b9942e3 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.types +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.types @@ -23,8 +23,8 @@ class C extends A { } var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; ->xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] ->[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] +>xs : ((x: A) => void)[] +>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[] >(x: A) => { } : (x: A) => void >x : A >A : A diff --git a/tests/baselines/reference/declFileClassExtendsNull.js b/tests/baselines/reference/declFileClassExtendsNull.js new file mode 100644 index 00000000000..0d50b320592 --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.js @@ -0,0 +1,23 @@ +//// [declFileClassExtendsNull.ts] + +class ExtendsNull extends null { +} + +//// [declFileClassExtendsNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var ExtendsNull = (function (_super) { + __extends(ExtendsNull, _super); + function ExtendsNull() { + _super.apply(this, arguments); + } + return ExtendsNull; +})(null); + + +//// [declFileClassExtendsNull.d.ts] +declare class ExtendsNull extends null { +} diff --git a/tests/baselines/reference/declFileClassExtendsNull.symbols b/tests/baselines/reference/declFileClassExtendsNull.symbols new file mode 100644 index 00000000000..e86276faad8 --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/declFileClassExtendsNull.ts === + +class ExtendsNull extends null { +>ExtendsNull : Symbol(ExtendsNull, Decl(declFileClassExtendsNull.ts, 0, 0)) +} diff --git a/tests/baselines/reference/declFileClassExtendsNull.types b/tests/baselines/reference/declFileClassExtendsNull.types new file mode 100644 index 00000000000..bbd43d99c0d --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/declFileClassExtendsNull.ts === + +class ExtendsNull extends null { +>ExtendsNull : ExtendsNull +>null : null +} diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index ea776d09910..5c2ce580507 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -34,6 +34,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var service_1 = require("./service"); var MyComponent = (function () { function MyComponent(Service) { this.Service = Service; diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.js b/tests/baselines/reference/decoratorMetadataWithConstructorType.js new file mode 100644 index 00000000000..1523915a390 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.js @@ -0,0 +1,39 @@ +//// [decoratorMetadataWithConstructorType.ts] + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x: A = new A(); +} + + +//// [decoratorMetadataWithConstructorType.js] +var A = (function () { + function A() { + console.log('new A'); + } + return A; +})(); +function decorator(target, propertyKey) { +} +var B = (function () { + function B() { + this.x = new A(); + } + __decorate([ + decorator, + __metadata('design:type', A) + ], B.prototype, "x"); + return B; +})(); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols b/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols new file mode 100644 index 00000000000..57221f0d139 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts === + +declare var console: { +>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11)) + + log(msg: string): void; +>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +>msg : Symbol(msg, Decl(decoratorMetadataWithConstructorType.ts, 2, 8)) + +}; + +class A { +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) + + constructor() { console.log('new A'); } +>console.log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11)) +>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +} + +function decorator(target: Object, propertyKey: string) { +>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1)) +>target : Symbol(target, Decl(decoratorMetadataWithConstructorType.ts, 9, 19)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataWithConstructorType.ts, 9, 34)) +} + +export class B { +>B : Symbol(B, Decl(decoratorMetadataWithConstructorType.ts, 10, 1)) + + @decorator +>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1)) + + x: A = new A(); +>x : Symbol(x, Decl(decoratorMetadataWithConstructorType.ts, 12, 16)) +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) +} + diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.types b/tests/baselines/reference/decoratorMetadataWithConstructorType.types new file mode 100644 index 00000000000..ad83706f4f9 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts === + +declare var console: { +>console : { log(msg: string): void; } + + log(msg: string): void; +>log : (msg: string) => void +>msg : string + +}; + +class A { +>A : A + + constructor() { console.log('new A'); } +>console.log('new A') : void +>console.log : (msg: string) => void +>console : { log(msg: string): void; } +>log : (msg: string) => void +>'new A' : string +} + +function decorator(target: Object, propertyKey: string) { +>decorator : (target: Object, propertyKey: string) => void +>target : Object +>Object : Object +>propertyKey : string +} + +export class B { +>B : B + + @decorator +>decorator : (target: Object, propertyKey: string) => void + + x: A = new A(); +>x : A +>A : A +>new A() : A +>A : typeof A +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js new file mode 100644 index 00000000000..392506e5368 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import {db} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols new file mode 100644 index 00000000000..c967239df99 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + +=== tests/cases/compiler/service.ts === +import {db} from './db'; +>db : Symbol(db, Decl(service.ts, 0, 8)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 8)) + + constructor(db: db) { +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 8)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types new file mode 100644 index 00000000000..60cf7f10cea --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import {db} from './db'; +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db; +>db : db +>db : db + + constructor(db: db) { +>db : db +>db : db + + this.db = db; +>this.db = db : db +>this.db : db +>this : MyClass +>db : db +>db : db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db +>this : MyClass +>db : db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js new file mode 100644 index 00000000000..da011acf110 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import {db as Database} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: Database; + + constructor(db: Database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols new file mode 100644 index 00000000000..d79b05f68f6 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols @@ -0,0 +1,52 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + +=== tests/cases/compiler/service.ts === +import {db as Database} from './db'; +>db : Symbol(Database, Decl(service.ts, 0, 8)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: Database; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + + constructor(db: Database) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types new file mode 100644 index 00000000000..73005b4673f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import {db as Database} from './db'; +>db : typeof Database +>Database : typeof Database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: Database; +>db : Database +>Database : Database + + constructor(db: Database) { // no collision +>db : Database +>Database : Database + + this.db = db; +>this.db = db : Database +>this.db : Database +>this : MyClass +>db : Database +>db : Database + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : Database +>this : MyClass +>db : Database +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js new file mode 100644 index 00000000000..b219bba4102 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import db = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { // collision with namespace of external module db + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols new file mode 100644 index 00000000000..b34468c7bd5 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/service.ts === +import db = require('./db'); +>db : Symbol(db, Decl(service.ts, 0, 0)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db.db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 0)) +>db : Symbol(db.db, Decl(db.ts, 0, 0)) + + constructor(db: db.db) { // collision with namespace of external module db +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 0)) +>db : Symbol(db.db, Decl(db.ts, 0, 0)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types new file mode 100644 index 00000000000..0eea3e13b66 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/service.ts === +import db = require('./db'); +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db.db; +>db : db.db +>db : any +>db : db.db + + constructor(db: db.db) { // collision with namespace of external module db +>db : db.db +>db : any +>db : db.db + + this.db = db; +>this.db = db : db.db +>this.db : db.db +>this : MyClass +>db : db.db +>db : db.db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db.db +>this : MyClass +>db : db.db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt new file mode 100644 index 00000000000..611a0804812 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/service.ts(1,8): error TS1192: Module '"tests/cases/compiler/db"' has no default export. + + +==== tests/cases/compiler/db.ts (0 errors) ==== + export class db { + public doSomething() { + } + } + +==== tests/cases/compiler/service.ts (1 errors) ==== + import db from './db'; // error no default export + ~~ +!!! error TS1192: Module '"tests/cases/compiler/db"' has no default export. + function someDecorator(target) { + return target; + } + @someDecorator + class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } + } + export {MyClass}; + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js new file mode 100644 index 00000000000..d0d201e62b5 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; // error no default export +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); // error no default export +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js new file mode 100644 index 00000000000..a2599515338 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { // collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols new file mode 100644 index 00000000000..6047d7f2882 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25)) + } +} + +=== tests/cases/compiler/service.ts === +import db from './db'; +>db : Symbol(db, Decl(service.ts, 0, 6)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 6)) + + constructor(db: db) { // collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 6)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types new file mode 100644 index 00000000000..0fbc48db157 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import db from './db'; +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db; +>db : db +>db : db + + constructor(db: db) { // collision +>db : db +>db : db + + this.db = db; +>this.db = db : db +>this.db : db +>this : MyClass +>db : db +>db : db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db +>this : MyClass +>db : db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js new file mode 100644 index 00000000000..917cdc7036f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import database from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database; + + constructor(db: database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols new file mode 100644 index 00000000000..27f807503bf --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25)) + } +} + +=== tests/cases/compiler/service.ts === +import database from './db'; +>database : Symbol(database, Decl(service.ts, 0, 6)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: database; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>database : Symbol(database, Decl(service.ts, 0, 6)) + + constructor(db: database) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>database : Symbol(database, Decl(service.ts, 0, 6)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types new file mode 100644 index 00000000000..e3a68882dfb --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import database from './db'; +>database : typeof database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: database; +>db : database +>database : database + + constructor(db: database) { // no collision +>db : database +>database : database + + this.db = db; +>this.db = db : database +>this.db : database +>this : MyClass +>db : database +>db : database + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : database +>this : MyClass +>db : database +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt new file mode 100644 index 00000000000..d4b714f1d4a --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/service.ts(7,9): error TS2503: Cannot find namespace 'db'. +tests/cases/compiler/service.ts(9,21): error TS2503: Cannot find namespace 'db'. + + +==== tests/cases/compiler/db.ts (0 errors) ==== + export default class db { + public doSomething() { + } + } + +==== tests/cases/compiler/service.ts (2 errors) ==== + import db from './db'; + function someDecorator(target) { + return target; + } + @someDecorator + class MyClass { + db: db.db; //error + ~~ +!!! error TS2503: Cannot find namespace 'db'. + + constructor(db: db.db) { // error + ~~ +!!! error TS2503: Cannot find namespace 'db'. + this.db = db; + this.db.doSomething(); + } + } + export {MyClass}; + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js new file mode 100644 index 00000000000..1dd93b12915 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; //error + + constructor(db: db.db) { // error + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js new file mode 100644 index 00000000000..0aee9e471dd --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import database = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database.db; + + constructor(db: database.db) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var database = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [database.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols new file mode 100644 index 00000000000..1b73ea2e9a3 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/service.ts === +import database = require('./db'); +>database : Symbol(database, Decl(service.ts, 0, 0)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: database.db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>database : Symbol(database, Decl(service.ts, 0, 0)) +>db : Symbol(database.db, Decl(db.ts, 0, 0)) + + constructor(db: database.db) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>database : Symbol(database, Decl(service.ts, 0, 0)) +>db : Symbol(database.db, Decl(db.ts, 0, 0)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types new file mode 100644 index 00000000000..faaab056885 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/service.ts === +import database = require('./db'); +>database : typeof database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: database.db; +>db : database.db +>database : any +>db : database.db + + constructor(db: database.db) { // no collision +>db : database.db +>database : any +>db : database.db + + this.db = db; +>this.db = db : database.db +>this.db : database.db +>this : MyClass +>db : database.db +>db : database.db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : database.db +>this : MyClass +>db : database.db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt index dc2db292eb5..19bf8d1ff22 100644 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,28): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,36): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclara bar() { var r = super.foo({ a: 1 }); // { a: number } var r2 = super.foo({ a: 1, b: 2 }); // { a: number } - ~~~~~~~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. !!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; } diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index 9104232b499..24774958941 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index 1de0fd58bec..e8cfc29f3a0 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index 47e50b1df83..cfb38fde90b 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. Types of property '0' are incompatible. Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. @@ -43,7 +43,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 } var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. !!! error TS2345: Types of property '0' are incompatible. !!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 82f598cab60..e5275396346 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1721, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index c6ddee1f3ee..230e7158d32 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1721, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index cea34544501..e304c33e48e 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1721, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index 1965204e7b6..4a309471e64 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1721, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index f466f0c2d8f..e9760caa319 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -10,7 +10,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1721, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.js b/tests/baselines/reference/excessPropertyErrorsSuppressed.js new file mode 100644 index 00000000000..1673674c5f3 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.js @@ -0,0 +1,7 @@ +//// [excessPropertyErrorsSuppressed.ts] + +var x: { a: string } = { a: "hello", b: 42 }; // No error + + +//// [excessPropertyErrorsSuppressed.js] +var x = { a: "hello", b: 42 }; // No error diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols b/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols new file mode 100644 index 00000000000..01c2846d3e1 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts === + +var x: { a: string } = { a: "hello", b: 42 }; // No error +>x : Symbol(x, Decl(excessPropertyErrorsSuppressed.ts, 1, 3)) +>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 8)) +>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 24)) +>b : Symbol(b, Decl(excessPropertyErrorsSuppressed.ts, 1, 36)) + diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.types b/tests/baselines/reference/excessPropertyErrorsSuppressed.types new file mode 100644 index 00000000000..47a4dbf92a9 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts === + +var x: { a: string } = { a: "hello", b: 42 }; // No error +>x : { a: string; } +>a : string +>{ a: "hello", b: 42 } : { a: string; b: number; } +>a : string +>"hello" : string +>b : number +>42 : number + diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index 6c1ec720b23..e465f36a50f 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1483, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1483, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 4119, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 4119, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index 066d9534051..76621026a00 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 8c34f6f0d7a..35892922df3 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 4e7aaf7e362..f01969e23bb 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index 70c1132afbd..c740cf62446 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 46507255937..bf4304a8216 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 8401de024d9..a45775127b0 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 93e918c4bcd..ef08deb568d 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 04445f50171..abaa0a92dcc 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index 4c645d359dd..727574805b9 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index 6887b46a44d..4e1bf8ad3dc 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index df31e8a3abf..e6a10d77cad 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1937, 1), Decl(lib.d.ts, 1960, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index 3cc94891811..43df250ab95 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1937, 1), Decl(lib.d.ts, 1960, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index d16986a1e7d..e1e413424ad 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1937, 1), Decl(lib.d.ts, 1960, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index a9ea283d673..839de020702 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index b9b7a2c23b8..87c227f5dc9 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1937, 1), Decl(lib.d.ts, 1960, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index 67926749791..c01a37bf409 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1937, 1), Decl(lib.d.ts, 1960, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index 8b717ade2ad..ff061ffcca1 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index 098afe94b47..53ecb88363d 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. for( var arr = [new C(), new C2(), new D()];;){} ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/forwardRefInEnum.errors.txt b/tests/baselines/reference/forwardRefInEnum.errors.txt new file mode 100644 index 00000000000..0f2c359402f --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/forwardRefInEnum.ts(4,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(5,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(7,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(8,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + + +==== tests/cases/compiler/forwardRefInEnum.ts (4 errors) ==== + enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + ~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + X1 = E1["Y"], + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + // forward reference to the element of the same enum + Y = E1.Z, + ~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + Y1 = E1["Z"] + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + } + + enum E1 { + Z = 4 + } + \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInEnum.js b/tests/baselines/reference/forwardRefInEnum.js new file mode 100644 index 00000000000..76e2575ec8d --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.js @@ -0,0 +1,31 @@ +//// [forwardRefInEnum.ts] +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} + + +//// [forwardRefInEnum.js] +var E1; +(function (E1) { + // illegal case + // forward reference to the element of the same enum + E1[E1["X"] = E1.Y] = "X"; + E1[E1["X1"] = E1["Y"]] = "X1"; + // forward reference to the element of the same enum + E1[E1["Y"] = E1.Z] = "Y"; + E1[E1["Y1"] = E1["Z"]] = "Y1"; +})(E1 || (E1 = {})); +var E1; +(function (E1) { + E1[E1["Z"] = 4] = "Z"; +})(E1 || (E1 = {})); diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index 4facd65bda7..1398e2974f0 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -342,7 +342,7 @@ var f7: (x: number) => string | number = x => { // should be (x: number) => numb var f8: (x: number) => any = x => { // should be (x: number) => Base >f8 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base >x : number return new Base(); @@ -356,7 +356,7 @@ var f8: (x: number) => any = x => { // should be (x: number) => Base var f9: (x: number) => any = x => { // should be (x: number) => Base >f9 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base | Derived | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base >x : number return new Base(); diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 06745d0d7aa..e8f434d31a8 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -2125,8 +2125,8 @@ var x216 = >{ func: n => { return [d1, d2]; } }; >d2 : Derived2 var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ->x217 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x217 : () => Base[] +>(<() => Base[]>undefined) || function() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2137,8 +2137,8 @@ var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ->x218 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x218 : () => Base[] +>(<() => Base[]>undefined) || function named() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2150,8 +2150,8 @@ var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ->x219 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x219 : () => Base[] +>(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2162,8 +2162,8 @@ var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ->x220 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x220 : () => Base[] +>(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2175,8 +2175,8 @@ var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x221 = (undefined) || [d1, d2]; ->x221 : Base[] | (Derived1 | Derived2)[] ->(undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x221 : Base[] +>(undefined) || [d1, d2] : Base[] >(undefined) : Base[] >undefined : Base[] >Base : Base @@ -2186,8 +2186,8 @@ var x221 = (undefined) || [d1, d2]; >d2 : Derived2 var x222 = (>undefined) || [d1, d2]; ->x222 : Base[] | (Derived1 | Derived2)[] ->(>undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x222 : Base[] +>(>undefined) || [d1, d2] : Base[] >(>undefined) : Base[] >>undefined : Base[] >Array : T[] @@ -2198,8 +2198,8 @@ var x222 = (>undefined) || [d1, d2]; >d2 : Derived2 var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; ->x223 : { [n: number]: Base; } | (Derived1 | Derived2)[] ->(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } | (Derived1 | Derived2)[] +>x223 : { [n: number]: Base; } +>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } >(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; } ><{ [n: number]: Base; }>undefined : { [n: number]: Base; } >n : number @@ -2210,8 +2210,8 @@ var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; >d2 : Derived2 var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; ->x224 : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } ->(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } +>x224 : { n: Base[]; } +>(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } >(<{n: Base[]; } >undefined) : { n: Base[]; } ><{n: Base[]; } >undefined : { n: Base[]; } >n : Base[] diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols index 7f30b4f6797..f424048eeec 100644 --- a/tests/baselines/reference/generatorES6_6.symbols +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(generatorES6_6.ts, 0, 0)) *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) let a = yield 1; >a : Symbol(a, Decl(generatorES6_6.ts, 2, 7)) diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols index 3346ef04a61..647576d081e 100644 --- a/tests/baselines/reference/generatorOverloads4.symbols +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -5,15 +5,15 @@ class C { f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) *f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) } diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols index 98fd5480277..e876a2619d2 100644 --- a/tests/baselines/reference/generatorOverloads5.symbols +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -5,15 +5,15 @@ module M { function f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) function f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) function* f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) } diff --git a/tests/baselines/reference/generatorTypeCheck1.symbols b/tests/baselines/reference/generatorTypeCheck1.symbols index a07f1495149..728084f01d0 100644 --- a/tests/baselines/reference/generatorTypeCheck1.symbols +++ b/tests/baselines/reference/generatorTypeCheck1.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === function* g1(): Iterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck1.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1692, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck10.symbols b/tests/baselines/reference/generatorTypeCheck10.symbols index 152af5cf51a..f00d72007f5 100644 --- a/tests/baselines/reference/generatorTypeCheck10.symbols +++ b/tests/baselines/reference/generatorTypeCheck10.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck10.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) return; } diff --git a/tests/baselines/reference/generatorTypeCheck11.symbols b/tests/baselines/reference/generatorTypeCheck11.symbols index d8a645be168..48a1abfbaca 100644 --- a/tests/baselines/reference/generatorTypeCheck11.symbols +++ b/tests/baselines/reference/generatorTypeCheck11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck11.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) return 0; } diff --git a/tests/baselines/reference/generatorTypeCheck12.symbols b/tests/baselines/reference/generatorTypeCheck12.symbols index a32faac2c98..745e4831b12 100644 --- a/tests/baselines/reference/generatorTypeCheck12.symbols +++ b/tests/baselines/reference/generatorTypeCheck12.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck12.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) return ""; } diff --git a/tests/baselines/reference/generatorTypeCheck13.symbols b/tests/baselines/reference/generatorTypeCheck13.symbols index 8eedde6975c..c6189a6ef64 100644 --- a/tests/baselines/reference/generatorTypeCheck13.symbols +++ b/tests/baselines/reference/generatorTypeCheck13.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck13.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) yield 0; return ""; diff --git a/tests/baselines/reference/generatorTypeCheck17.symbols b/tests/baselines/reference/generatorTypeCheck17.symbols index 4477ee5d954..51d6c40ae37 100644 --- a/tests/baselines/reference/generatorTypeCheck17.symbols +++ b/tests/baselines/reference/generatorTypeCheck17.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck17.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck19.symbols b/tests/baselines/reference/generatorTypeCheck19.symbols index 9761524bcf3..12bf5e5e34e 100644 --- a/tests/baselines/reference/generatorTypeCheck19.symbols +++ b/tests/baselines/reference/generatorTypeCheck19.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck19.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck2.symbols b/tests/baselines/reference/generatorTypeCheck2.symbols index 4b78ce3cd79..c03276b6c9b 100644 --- a/tests/baselines/reference/generatorTypeCheck2.symbols +++ b/tests/baselines/reference/generatorTypeCheck2.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === function* g1(): Iterable { } >g1 : Symbol(g1, Decl(generatorTypeCheck2.ts, 0, 0)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck26.symbols b/tests/baselines/reference/generatorTypeCheck26.symbols index bdb2934d24a..399e4ccc497 100644 --- a/tests/baselines/reference/generatorTypeCheck26.symbols +++ b/tests/baselines/reference/generatorTypeCheck26.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck26.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >x : Symbol(x, Decl(generatorTypeCheck26.ts, 0, 33)) yield x => x.length; diff --git a/tests/baselines/reference/generatorTypeCheck27.symbols b/tests/baselines/reference/generatorTypeCheck27.symbols index b42926b1155..3d0a66382c6 100644 --- a/tests/baselines/reference/generatorTypeCheck27.symbols +++ b/tests/baselines/reference/generatorTypeCheck27.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck27.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >x : Symbol(x, Decl(generatorTypeCheck27.ts, 0, 33)) yield * function* () { diff --git a/tests/baselines/reference/generatorTypeCheck28.symbols b/tests/baselines/reference/generatorTypeCheck28.symbols index 45788752137..96ce1e27c63 100644 --- a/tests/baselines/reference/generatorTypeCheck28.symbols +++ b/tests/baselines/reference/generatorTypeCheck28.symbols @@ -1,14 +1,14 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck28.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >x : Symbol(x, Decl(generatorTypeCheck28.ts, 0, 33)) yield * { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) yield x => x.length; >x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) diff --git a/tests/baselines/reference/generatorTypeCheck29.symbols b/tests/baselines/reference/generatorTypeCheck29.symbols index c0fb32e8d5a..b01b97eb763 100644 --- a/tests/baselines/reference/generatorTypeCheck29.symbols +++ b/tests/baselines/reference/generatorTypeCheck29.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck29.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1692, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(generatorTypeCheck29.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck3.symbols b/tests/baselines/reference/generatorTypeCheck3.symbols index 27300d72280..79a3164e2d2 100644 --- a/tests/baselines/reference/generatorTypeCheck3.symbols +++ b/tests/baselines/reference/generatorTypeCheck3.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === function* g1(): IterableIterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck3.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1702, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck30.symbols b/tests/baselines/reference/generatorTypeCheck30.symbols index befe5f7a96f..e337277aa43 100644 --- a/tests/baselines/reference/generatorTypeCheck30.symbols +++ b/tests/baselines/reference/generatorTypeCheck30.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck30.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1692, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(generatorTypeCheck30.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck45.symbols b/tests/baselines/reference/generatorTypeCheck45.symbols index 4bfc8e18afb..9cf40641ad6 100644 --- a/tests/baselines/reference/generatorTypeCheck45.symbols +++ b/tests/baselines/reference/generatorTypeCheck45.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck45.ts, 0, 32)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1692, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) diff --git a/tests/baselines/reference/generatorTypeCheck46.symbols b/tests/baselines/reference/generatorTypeCheck46.symbols index 677dd8aa5ae..8b3bf966681 100644 --- a/tests/baselines/reference/generatorTypeCheck46.symbols +++ b/tests/baselines/reference/generatorTypeCheck46.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck46.ts, 0, 32)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) @@ -21,9 +21,9 @@ foo("", function* () { yield* { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) yield x => x.length >x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) diff --git a/tests/baselines/reference/getEmitOutputOutFile.baseline b/tests/baselines/reference/getEmitOutputOutFile.baseline new file mode 100644 index 00000000000..702097a7c03 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputOutFile.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : outFile.js +var x = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var x1 = "hello world"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +FileName : outFile.d.ts +declare var x: number; +declare class Bar { + x: string; + y: number; +} +declare var x1: string; +declare class Foo { + x: string; + y: number; +} + diff --git a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline new file mode 100644 index 00000000000..2ae820dd538 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":["Bar","Bar.constructor"],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAAA;IAGAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +// regular ts file +var t = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +declare var t: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile2.jsx.map +{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.jsx +var y = "my div"; +var x =
; +//# sourceMappingURL=inputFile2.jsx.mapFileName : tests/cases/fourslash/inputFile2.d.ts +declare var y: string; +declare var x: any; + diff --git a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline new file mode 100644 index 00000000000..c796f8e78bc --- /dev/null +++ b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":["Bar","Bar.constructor"],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAAA;IAGAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +// regular ts file +var t = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +declare var t: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile2.js.map +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,KAAC,IAAI,GAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js +var y = "my div"; +var x = React.createElement("div", {"name": y}); +//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts +declare var y: string; +declare var x: any; + diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 952200d74f8..c760e5a566f 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -21,14 +21,14 @@ var c = [1, '', null]; // {}[] >null : null var d = [{}, 1]; // {}[] ->d : ({} | number)[] ->[{}, 1] : ({} | number)[] +>d : {}[] +>[{}, 1] : {}[] >{} : {} >1 : number var e = [{}, Object]; // {}[] ->e : ({} | ObjectConstructor)[] ->[{}, Object] : ({} | ObjectConstructor)[] +>e : {}[] +>[{}, Object] : {}[] >{} : {} >Object : ObjectConstructor @@ -88,16 +88,16 @@ var k = [() => 1, () => 1]; // { (): number }[] >1 : number var l = [() => 1, () => null]; // { (): any }[] ->l : ((() => number) | (() => any))[] ->[() => 1, () => null] : ((() => number) | (() => any))[] +>l : (() => any)[] +>[() => 1, () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => null : () => any >null : null var m = [() => 1, () => '', () => null]; // { (): any }[] ->m : ((() => number) | (() => string) | (() => any))[] ->[() => 1, () => '', () => null] : ((() => number) | (() => string) | (() => any))[] +>m : (() => any)[] +>[() => 1, () => '', () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => '' : () => string @@ -169,8 +169,8 @@ module Derived { >derived : Derived var j = [() => base, () => derived]; // { {}: Base } ->j : ((() => Base) | (() => Derived))[] ->[() => base, () => derived] : ((() => Base) | (() => Derived))[] +>j : (() => Base)[] +>[() => base, () => derived] : (() => Base)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -185,16 +185,16 @@ module Derived { >1 : number var l = [() => base, () => null]; // { (): any }[] ->l : ((() => Base) | (() => any))[] ->[() => base, () => null] : ((() => Base) | (() => any))[] +>l : (() => any)[] +>[() => base, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => null : () => any >null : null var m = [() => base, () => derived, () => null]; // { (): any }[] ->m : ((() => Base) | (() => Derived) | (() => any))[] ->[() => base, () => derived, () => null] : ((() => Base) | (() => Derived) | (() => any))[] +>m : (() => any)[] +>[() => base, () => derived, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -203,8 +203,8 @@ module Derived { >null : null var n = [[() => base], [() => derived]]; // { (): Base }[] ->n : ((() => Base)[] | (() => Derived)[])[] ->[[() => base], [() => derived]] : ((() => Base)[] | (() => Derived)[])[] +>n : (() => Base)[][] +>[[() => base], [() => derived]] : (() => Base)[][] >[() => base] : (() => Base)[] >() => base : () => Base >base : Base @@ -219,8 +219,8 @@ module Derived { >derived2 : Derived2 var p = [derived, derived2, base]; // Base[] ->p : (Derived | Derived2 | Base)[] ->[derived, derived2, base] : (Derived | Derived2 | Base)[] +>p : Base[] +>[derived, derived2, base] : Base[] >derived : Derived >derived2 : Derived2 >base : Base @@ -310,8 +310,8 @@ function foo(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -364,8 +364,8 @@ function foo2(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -374,8 +374,8 @@ function foo2(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -386,14 +386,14 @@ function foo2(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -442,8 +442,8 @@ function foo3(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -452,26 +452,26 @@ function foo3(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base var h = [t, derived]; // Derived[] ->h : (T | Derived)[] ->[t, derived] : (T | Derived)[] +>h : Derived[] +>[t, derived] : Derived[] >t : T >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -520,8 +520,8 @@ function foo4(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -530,8 +530,8 @@ function foo4(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -542,8 +542,8 @@ function foo4(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index e8763b0d54c..e612600a7f8 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -18,9 +18,9 @@ tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2345: Argument of type Types of property 'p1' are incompatible. Type '() => string' is not assignable to type '(s: string) => number'. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/incompatibleTypes.ts(49,5): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. +tests/cases/compiler/incompatibleTypes.ts(49,7): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. -tests/cases/compiler/incompatibleTypes.ts(66,5): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. +tests/cases/compiler/incompatibleTypes.ts(66,47): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. tests/cases/compiler/incompatibleTypes.ts(72,5): error TS2322: Type 'number' is not assignable to type '() => string'. tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => number' is not assignable to type '() => any'. @@ -101,7 +101,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => function of1(a: any) { return null; } of1({ e: 0, f: 0 }); - ~~~~~~~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. !!! error TS2345: Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. @@ -121,7 +121,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => } var o1: { a: { a: string; }; b: string; } = { e: 0, f: 0 }; - ~~ + ~~~~ !!! error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. diff --git a/tests/baselines/reference/inlineSourceMap2.errors.txt b/tests/baselines/reference/inlineSourceMap2.errors.txt index 2d8bc4be0c1..24b0fddf942 100644 --- a/tests/baselines/reference/inlineSourceMap2.errors.txt +++ b/tests/baselines/reference/inlineSourceMap2.errors.txt @@ -1,12 +1,12 @@ -error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. -error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'. -!!! error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -!!! error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. -!!! error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. ==== tests/cases/compiler/inlineSourceMap2.ts (1 errors) ==== // configuration errors diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index 0c4b95214b0..3ec718f3b25 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. var arr = [new C(), new C2(), new D()]; ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/isolatedModulesDeclaration.errors.txt b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt index de5cb97586c..749e86116e8 100644 --- a/tests/baselines/reference/isolatedModulesDeclaration.errors.txt +++ b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt @@ -1,7 +1,7 @@ -error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'. -!!! error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/isolatedModulesDeclaration.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt index 68b2747cf6b..337fcb16ba3 100644 --- a/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt +++ b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt @@ -1,7 +1,7 @@ -error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. -!!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/isolatedModulesNoEmitOnError.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesOut.errors.txt b/tests/baselines/reference/isolatedModulesOut.errors.txt index 8234ba94585..7d16ac94666 100644 --- a/tests/baselines/reference/isolatedModulesOut.errors.txt +++ b/tests/baselines/reference/isolatedModulesOut.errors.txt @@ -1,8 +1,8 @@ -error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. -!!! error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/file1.ts (0 errors) ==== export var x; diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index 3920dc1cef4..fae627e9c95 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 06e38c57af4..fefeaced83f 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index e16fe5255e4..fd00059449a 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index b8709197829..8271e564f9e 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 17ac6a1feac..d4f2949e24f 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 468866ca324..9e38c52ad70 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index a3bbbbf0956..523d81cde2d 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1937, 1), Decl(lib.d.ts, 1960, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index 10225e183e6..d3a7f4fb1d7 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 86c46812688..efb88d2e608 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index c2ff8760e29..52f5f2d0b17 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index c4a2459e262..03099b124c9 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index 2f1a7234571..c18c9095f50 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index cdc7bb3e2bc..906e8288af0 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index e4d1b508bb5..e25374c80a8 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index bd6760dd0aa..1856d1bb682 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index d0bc9790752..c68550b7fa7 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index a7e5d7b8919..874a034631d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 67b9e9e500d..0f84a0e1cbb 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index 0c3c11c84f4..6f329329431 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 03faf4b593e..01a0112b026 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/jsxHash.types b/tests/baselines/reference/jsxHash.types index e614ebd3e0b..6d413141ca6 100644 --- a/tests/baselines/reference/jsxHash.types +++ b/tests/baselines/reference/jsxHash.types @@ -3,18 +3,21 @@ var t02 = {0}#; >t02 : any >{0}# : any >a : any +>0 : number >a : any var t03 = #{0}; >t03 : any >#{0} : any >a : any +>0 : number >a : any var t04 = #{0}#; >t04 : any >#{0}# : any >a : any +>0 : number >a : any var t05 = #; diff --git a/tests/baselines/reference/jsxImportInAttribute.symbols b/tests/baselines/reference/jsxImportInAttribute.symbols index 8481771f085..845001b22c0 100644 --- a/tests/baselines/reference/jsxImportInAttribute.symbols +++ b/tests/baselines/reference/jsxImportInAttribute.symbols @@ -9,6 +9,7 @@ let x = Test; // emit test_1.default ; // ? >attr : Symbol(unknown) +>Test : Symbol(Test, Decl(consumer.tsx, 1, 6)) === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxImportInAttribute.types b/tests/baselines/reference/jsxImportInAttribute.types index 8dfbe292fe0..8dc5c370fa8 100644 --- a/tests/baselines/reference/jsxImportInAttribute.types +++ b/tests/baselines/reference/jsxImportInAttribute.types @@ -11,7 +11,7 @@ let x = Test; // emit test_1.default > : any >anything : any >attr : any ->Test : any +>Test : typeof Test === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols index ba329949939..1fe64cbfdd7 100644 --- a/tests/baselines/reference/jsxReactTestSuite.symbols +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -46,6 +46,8 @@ declare var hasOwnProperty:any;

{foo}
{bar}
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>foo : Symbol(foo, Decl(jsxReactTestSuite.tsx, 7, 11)) +>bar : Symbol(bar, Decl(jsxReactTestSuite.tsx, 8, 11)) >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
@@ -159,6 +161,7 @@ var x = ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(unknown) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) ; diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types index db7ebf8d912..88c2c278e59 100644 --- a/tests/baselines/reference/jsxReactTestSuite.types +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -251,6 +251,7 @@ var x = >y : any ={2 } z />; +>2 : number >z : any Component : any >x : any >y : any +>2 : number ; > : any >Component : any >x : any >y : any +>2 : number >z : any ; > : any >Component : any >x : any +>1 : number >y : any @@ -306,6 +310,7 @@ var x = > : any >Component : any >x : any +>1 : number >y : any >z : any >z : any @@ -326,6 +331,7 @@ var x = >2 : number >z : any >z : any +>3 : number >Component : any diff --git a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt index bd210c55570..484c8f63b46 100644 --- a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt +++ b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts(6,5): error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. +tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts(6,33): error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. @@ -10,7 +10,7 @@ tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrE // operand types. var r: { a: string } = { a: '', b: 123 } || { a: '', b: true }; - ~ + ~~~~~~ !!! error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. !!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 04bc188e308..4540e35aaf4 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -187,8 +187,8 @@ var rc5 = a5 || a3; // void || number is void | number >a3 : number var rc6 = a6 || a3; // enum || number is number ->rc6 : E | number ->a6 || a3 : E | number +>rc6 : number +>a6 || a3 : number >a6 : E >a3 : number @@ -349,8 +349,8 @@ var rg2 = a2 || a6; // boolean || enum is boolean | enum >a6 : E var rg3 = a3 || a6; // number || enum is number ->rg3 : number | E ->a3 || a6 : number | E +>rg3 : number +>a3 || a6 : number >a3 : number >a6 : E diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index df8f6cac6db..f887ad7ae14 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -107,8 +107,8 @@ function fn3u : U var r3 = t || { a: '' }; ->r3 : T | { a: string; } ->t || { a: '' } : T | { a: string; } +>r3 : { a: string; } +>t || { a: '' } : { a: string; } >t : T >{ a: '' } : { a: string; } >a : string diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt new file mode 100644 index 00000000000..b7331a68271 --- /dev/null +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'. + + +==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ==== + class George extends class { reset() { return this.y; } } { + ~ +!!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'. + constructor() { + super(); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.js b/tests/baselines/reference/missingPropertiesOfClassExpression.js new file mode 100644 index 00000000000..f427da20f0c --- /dev/null +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.js @@ -0,0 +1,26 @@ +//// [missingPropertiesOfClassExpression.ts] +class George extends class { reset() { return this.y; } } { + constructor() { + super(); + } +} + + +//// [missingPropertiesOfClassExpression.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var George = (function (_super) { + __extends(George, _super); + function George() { + _super.call(this); + } + return George; +})((function () { + function class_1() { + } + class_1.prototype.reset = function () { return this.y; }; + return class_1; +})()); diff --git a/tests/baselines/reference/moduleResolutionNoResolve.js b/tests/baselines/reference/moduleResolutionNoResolve.js new file mode 100644 index 00000000000..9f0537a5ad5 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/moduleResolutionNoResolve.ts] //// + +//// [a.ts] + +import a = require('./b'); + +//// [b.ts] +export var c = ''; + + +//// [a.js] +//// [b.js] +exports.c = ''; diff --git a/tests/baselines/reference/moduleResolutionNoResolve.symbols b/tests/baselines/reference/moduleResolutionNoResolve.symbols new file mode 100644 index 00000000000..17ccfeab496 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +import a = require('./b'); +>a : Symbol(a, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +export var c = ''; +>c : Symbol(c, Decl(b.ts, 0, 10)) + diff --git a/tests/baselines/reference/moduleResolutionNoResolve.types b/tests/baselines/reference/moduleResolutionNoResolve.types new file mode 100644 index 00000000000..3e96ed2b197 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/a.ts === + +import a = require('./b'); +>a : typeof a + +=== tests/cases/compiler/b.ts === +export var c = ''; +>c : string +>'' : string + diff --git a/tests/baselines/reference/nodeResolution1.js b/tests/baselines/reference/nodeResolution1.js new file mode 100644 index 00000000000..3516342e3b2 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/nodeResolution1.ts] //// + +//// [a.ts] + +export var x = 1; + +//// [b.ts] +import y = require("./a"); + +//// [a.js] +exports.x = 1; +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution1.symbols b/tests/baselines/reference/nodeResolution1.symbols new file mode 100644 index 00000000000..0cc98206e90 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/a.ts === + +export var x = 1; +>x : Symbol(x, Decl(a.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution1.types b/tests/baselines/reference/nodeResolution1.types new file mode 100644 index 00000000000..4f29acfcc03 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : typeof y + +=== tests/cases/compiler/a.ts === + +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/nodeResolution2.js b/tests/baselines/reference/nodeResolution2.js new file mode 100644 index 00000000000..a5935461088 --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/nodeResolution2.ts] //// + +//// [a.d.ts] + +export var x: number; + +//// [b.ts] +import y = require("a"); + +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution2.symbols b/tests/baselines/reference/nodeResolution2.symbols new file mode 100644 index 00000000000..643d285e7b8 --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/a.d.ts === + +export var x: number; +>x : Symbol(x, Decl(a.d.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution2.types b/tests/baselines/reference/nodeResolution2.types new file mode 100644 index 00000000000..896af7f8bda --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : typeof y + +=== tests/cases/compiler/node_modules/a.d.ts === + +export var x: number; +>x : number + diff --git a/tests/baselines/reference/nodeResolution3.js b/tests/baselines/reference/nodeResolution3.js new file mode 100644 index 00000000000..6e0ec608323 --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/nodeResolution3.ts] //// + +//// [index.d.ts] + +export var x: number; + +//// [a.ts] +import y = require("b"); + +//// [a.js] diff --git a/tests/baselines/reference/nodeResolution3.symbols b/tests/baselines/reference/nodeResolution3.symbols new file mode 100644 index 00000000000..0fca588676f --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === +import y = require("b"); +>y : Symbol(y, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/b/index.d.ts === + +export var x: number; +>x : Symbol(x, Decl(index.d.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution3.types b/tests/baselines/reference/nodeResolution3.types new file mode 100644 index 00000000000..82a1ccb27d3 --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === +import y = require("b"); +>y : typeof y + +=== tests/cases/compiler/node_modules/b/index.d.ts === + +export var x: number; +>x : number + diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 71e164d5d62..ff18160e9a5 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Index signatures are incompatible. - Type 'A | B | number' is not assignable to type 'A'. + Type 'A | number' is not assignable to type 'A'. Type 'number' is not assignable to type 'A'. @@ -54,9 +54,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'A | B | number' is not assignable to type 'A'. +!!! error TS2322: Type 'A | number' is not assignable to type 'A'. !!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), diff --git a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt index 465c4d6d9f6..1b79e4db5ad 100644 --- a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt +++ b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,5): error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. +tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,27): error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. ==== tests/cases/compiler/objectLitStructuralTypeMismatch.ts (1 errors) ==== // Shouldn't compile var x: { a: number; } = { b: 5 }; - ~ + ~~~~ !!! error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt index 149aca43a42..fb2cbdaf649 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,6): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and 'hello' does not exist in type 'I'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and 'what' does not exist in type 'I'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(11,4): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'. Property 'value' is missing in type '{ toString: (s: string) => string; }'. @@ -18,12 +18,12 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(13,36): error T function f2(args: I) { } f2({ hello: 1 }) // error - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. !!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I'. f2({ value: '' }) // missing toString satisfied by Object's member f2({ value: '', what: 1 }) // missing toString satisfied by Object's member - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I'. f2({ toString: (s) => s }) // error, missing property value from ArgsString diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt index 367a676abc6..b967b227809 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,6): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. Property 'doStuff' is missing in type '{ value: string; }'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'what' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,4): error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. Property 'value' is missing in type '{ toString: (s: any) => any; }'. @@ -21,7 +21,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T function f2(args: I2) { } f2({ hello: 1 }) - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. f2({ value: '' }) @@ -29,7 +29,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T !!! error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Property 'doStuff' is missing in type '{ value: string; }'. f2({ value: '', what: 1 }) - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I2'. f2({ toString: (s) => s }) diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index edb6d031b1f..c35e49f02a3 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Index signatures are incompatible. Type 'A' is not assignable to type 'B'. @@ -18,7 +18,7 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'A' is not assignable to type 'B'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index 55cec857c70..d5add00ebaf 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,7 +31,7 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { [x: string]: A | B; [x: number]: B; 0: B; x: A; } +>{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; } >x : A >a : A >b : B diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index d00a8ddf074..50839d5e56b 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error - ~~~~~~ + ~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. var person1: { name, id }; // error: can't use short-hand property assignment in type position diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index f6f4f625c45..b4f695c835d 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error - ~~~~~~ + ~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error diff --git a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt index 47401a7ae8b..f108f0ea92d 100644 --- a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt +++ b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(19,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(19,5): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(22,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. -tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,5): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. @@ -25,7 +25,7 @@ tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS234 var v: B; v({ s: "", n: 0 }).toLowerCase(); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. !!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. @@ -35,6 +35,6 @@ tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS234 !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. w({ s: "", n: 0 }).toLowerCase(); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. !!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.js b/tests/baselines/reference/out-flag2.js new file mode 100644 index 00000000000..e2a30f169e3 --- /dev/null +++ b/tests/baselines/reference/out-flag2.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/out-flag2.ts] //// + +//// [a.ts] + +class A { } + +//// [b.ts] +class B { } + +//// [c.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +//# sourceMappingURL=c.js.map + +//// [c.d.ts] +declare class A { +} +declare class B { +} diff --git a/tests/baselines/reference/out-flag2.js.map b/tests/baselines/reference/out-flag2.js.map new file mode 100644 index 00000000000..c1523e75784 --- /dev/null +++ b/tests/baselines/reference/out-flag2.js.map @@ -0,0 +1,2 @@ +//// [c.js.map] +{"version":3,"file":"c.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":"AACA;IAAAA;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW;ACDX;IAAAE;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.sourcemap.txt b/tests/baselines/reference/out-flag2.sourcemap.txt new file mode 100644 index 00000000000..6a67e61bc91 --- /dev/null +++ b/tests/baselines/reference/out-flag2.sourcemap.txt @@ -0,0 +1,104 @@ +=================================================================== +JsFile: c.js +mapUrl: c.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(2, 5) Source(2, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class A { +2 > } +1->Emitted(3, 5) Source(2, 11) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(2, 12) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(4, 5) Source(2, 11) + SourceIndex(0) name (A) +2 >Emitted(4, 13) Source(2, 12) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A { } +1 >Emitted(5, 1) Source(2, 11) + SourceIndex(0) name (A) +2 >Emitted(5, 2) Source(2, 12) + SourceIndex(0) name (A) +3 >Emitted(5, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(5, 6) Source(2, 12) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var B = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(6, 1) Source(1, 1) + SourceIndex(1) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(7, 5) Source(1, 1) + SourceIndex(1) name (B) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class B { +2 > } +1->Emitted(8, 5) Source(1, 11) + SourceIndex(1) name (B.constructor) +2 >Emitted(8, 6) Source(1, 12) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(9, 5) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(9, 13) Source(1, 12) + SourceIndex(1) name (B) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class B { } +1 >Emitted(10, 1) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(10, 2) Source(1, 12) + SourceIndex(1) name (B) +3 >Emitted(10, 2) Source(1, 1) + SourceIndex(1) +4 >Emitted(10, 6) Source(1, 12) + SourceIndex(1) +--- +>>>//# sourceMappingURL=c.js.map \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.symbols b/tests/baselines/reference/out-flag2.symbols new file mode 100644 index 00000000000..1bca057c580 --- /dev/null +++ b/tests/baselines/reference/out-flag2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +class A { } +>A : Symbol(A, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +class B { } +>B : Symbol(B, Decl(b.ts, 0, 0)) + diff --git a/tests/baselines/reference/out-flag2.types b/tests/baselines/reference/out-flag2.types new file mode 100644 index 00000000000..5a13642f99f --- /dev/null +++ b/tests/baselines/reference/out-flag2.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +class A { } +>A : A + +=== tests/cases/compiler/b.ts === +class B { } +>B : B + diff --git a/tests/baselines/reference/out-flag3.errors.txt b/tests/baselines/reference/out-flag3.errors.txt new file mode 100644 index 00000000000..6b7dda7c962 --- /dev/null +++ b/tests/baselines/reference/out-flag3.errors.txt @@ -0,0 +1,12 @@ +error TS5053: Option 'out' cannot be specified with option 'outFile'. + + +!!! error TS5053: Option 'out' cannot be specified with option 'outFile'. +==== tests/cases/compiler/a.ts (0 errors) ==== + + // --out and --outFile error + + class A { } + +==== tests/cases/compiler/b.ts (0 errors) ==== + class B { } \ No newline at end of file diff --git a/tests/baselines/reference/out-flag3.js b/tests/baselines/reference/out-flag3.js new file mode 100644 index 00000000000..8327c3429d3 --- /dev/null +++ b/tests/baselines/reference/out-flag3.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/out-flag3.ts] //// + +//// [a.ts] + +// --out and --outFile error + +class A { } + +//// [b.ts] +class B { } + +//// [c.js] +// --out and --outFile error +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +//# sourceMappingURL=c.js.map + +//// [c.d.ts] +declare class A { +} +declare class B { +} diff --git a/tests/baselines/reference/out-flag3.js.map b/tests/baselines/reference/out-flag3.js.map new file mode 100644 index 00000000000..a52d66589c7 --- /dev/null +++ b/tests/baselines/reference/out-flag3.js.map @@ -0,0 +1,2 @@ +//// [c.js.map] +{"version":3,"file":"c.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":"AACA,4BAA4B;AAE5B;IAAAA;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW;ACHX;IAAAE;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag3.sourcemap.txt b/tests/baselines/reference/out-flag3.sourcemap.txt new file mode 100644 index 00000000000..c30c9f63020 --- /dev/null +++ b/tests/baselines/reference/out-flag3.sourcemap.txt @@ -0,0 +1,114 @@ +=================================================================== +JsFile: c.js +mapUrl: c.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>// --out and --outFile error +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > +2 >// --out and --outFile error +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 29) Source(2, 29) + SourceIndex(0) +--- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > + > +1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class A { +2 > } +1->Emitted(4, 5) Source(4, 11) + SourceIndex(0) name (A.constructor) +2 >Emitted(4, 6) Source(4, 12) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(5, 5) Source(4, 11) + SourceIndex(0) name (A) +2 >Emitted(5, 13) Source(4, 12) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A { } +1 >Emitted(6, 1) Source(4, 11) + SourceIndex(0) name (A) +2 >Emitted(6, 2) Source(4, 12) + SourceIndex(0) name (A) +3 >Emitted(6, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(6, 6) Source(4, 12) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var B = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(7, 1) Source(1, 1) + SourceIndex(1) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(8, 5) Source(1, 1) + SourceIndex(1) name (B) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class B { +2 > } +1->Emitted(9, 5) Source(1, 11) + SourceIndex(1) name (B.constructor) +2 >Emitted(9, 6) Source(1, 12) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(10, 5) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(10, 13) Source(1, 12) + SourceIndex(1) name (B) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class B { } +1 >Emitted(11, 1) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(11, 2) Source(1, 12) + SourceIndex(1) name (B) +3 >Emitted(11, 2) Source(1, 1) + SourceIndex(1) +4 >Emitted(11, 6) Source(1, 12) + SourceIndex(1) +--- +>>>//# sourceMappingURL=c.js.map \ No newline at end of file diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index 1423901a28f..61ec1a24ec5 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -149,8 +149,8 @@ var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >i : number >fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => x : x => undefined) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? x => x : x => undefined : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any +>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -169,8 +169,8 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >j : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -191,8 +191,8 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >k : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -216,9 +216,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >l : number >fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : ((x: number) => number) | ((x: number) => any) ->(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : ((x: number) => number) | ((x: number) => any) +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index 344933ea1fc..a055f2f1bbd 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -186,8 +186,8 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >i : number >fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -209,8 +209,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >j : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -234,8 +234,8 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >k : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -265,9 +265,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >l : number >fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 5d97b2d7a01..f21959df892 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index 69764d70b45..9f43ba7b006 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index c42bb3abb83..e3a3b1d5609 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index ba93afde837..ba0134e82a9 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index 4829677f516..970f8a0b753 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 793b925b382..29831fad7ef 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index e1b85f2a3b9..8322d312839 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index 05b002eb569..7c5dfbff7c6 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index 774eb2dcc4b..7ee5e7e6998 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt index bef02272064..44d2c93d9a5 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt index bef02272064..44d2c93d9a5 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt index d00f552ef97..97e3ed02cf9 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt index d00f552ef97..97e3ed02cf9 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt index f4b65c12f35..56dab79dacf 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt index f4b65c12f35..56dab79dacf 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index cf906e0359d..b12d564d880 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4900, 39), Decl(lib.d.ts, 4907, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4900, 39), Decl(lib.d.ts, 4907, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 5109, 39), Decl(lib.d.ts, 5116, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 5109, 39), Decl(lib.d.ts, 5116, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4837, 22), Decl(lib.d.ts, 4844, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4837, 22), Decl(lib.d.ts, 4844, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4837, 22), Decl(lib.d.ts, 4844, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4837, 22), Decl(lib.d.ts, 4844, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/recursiveTupleTypes1.js b/tests/baselines/reference/recursiveTupleTypes1.js new file mode 100644 index 00000000000..f4fa8ef4816 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.js @@ -0,0 +1,20 @@ +//// [recursiveTupleTypes1.ts] +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree1]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; + + +//// [recursiveTupleTypes1.js] +var tree1; +var tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/baselines/reference/recursiveTupleTypes1.symbols b/tests/baselines/reference/recursiveTupleTypes1.symbols new file mode 100644 index 00000000000..8bd0797f3f6 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/recursiveTupleTypes1.ts === +interface Tree1 { +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) + + children: [Tree1, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 0, 17)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) +} + +interface Tree2 { +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) + + children: [Tree2, Tree1]; +>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 4, 17)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) +} + +let tree1: Tree1; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) + +let tree2: Tree2; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) + +tree1 = tree2; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) + +tree2 = tree1; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) + diff --git a/tests/baselines/reference/recursiveTupleTypes1.types b/tests/baselines/reference/recursiveTupleTypes1.types new file mode 100644 index 00000000000..9dfdc768ddb --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/recursiveTupleTypes1.ts === +interface Tree1 { +>Tree1 : Tree1 + + children: [Tree1, Tree2]; +>children : [Tree1, Tree2] +>Tree1 : Tree1 +>Tree2 : Tree2 +} + +interface Tree2 { +>Tree2 : Tree2 + + children: [Tree2, Tree1]; +>children : [Tree2, Tree1] +>Tree2 : Tree2 +>Tree1 : Tree1 +} + +let tree1: Tree1; +>tree1 : Tree1 +>Tree1 : Tree1 + +let tree2: Tree2; +>tree2 : Tree2 +>Tree2 : Tree2 + +tree1 = tree2; +>tree1 = tree2 : Tree2 +>tree1 : Tree1 +>tree2 : Tree2 + +tree2 = tree1; +>tree2 = tree1 : Tree1 +>tree2 : Tree2 +>tree1 : Tree1 + diff --git a/tests/baselines/reference/recursiveTupleTypes2.js b/tests/baselines/reference/recursiveTupleTypes2.js new file mode 100644 index 00000000000..60dde8ef4d5 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.js @@ -0,0 +1,20 @@ +//// [recursiveTupleTypes2.ts] +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree2]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; + + +//// [recursiveTupleTypes2.js] +var tree1; +var tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/baselines/reference/recursiveTupleTypes2.symbols b/tests/baselines/reference/recursiveTupleTypes2.symbols new file mode 100644 index 00000000000..2895f1b5669 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/recursiveTupleTypes2.ts === +interface Tree1 { +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) + + children: [Tree1, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 0, 17)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +} + +interface Tree2 { +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) + + children: [Tree2, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 4, 17)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +} + +let tree1: Tree1; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) + +let tree2: Tree2; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) + +tree1 = tree2; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) + +tree2 = tree1; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) + diff --git a/tests/baselines/reference/recursiveTupleTypes2.types b/tests/baselines/reference/recursiveTupleTypes2.types new file mode 100644 index 00000000000..9ce8e5daf79 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/recursiveTupleTypes2.ts === +interface Tree1 { +>Tree1 : Tree1 + + children: [Tree1, Tree2]; +>children : [Tree1, Tree2] +>Tree1 : Tree1 +>Tree2 : Tree2 +} + +interface Tree2 { +>Tree2 : Tree2 + + children: [Tree2, Tree2]; +>children : [Tree2, Tree2] +>Tree2 : Tree2 +>Tree2 : Tree2 +} + +let tree1: Tree1; +>tree1 : Tree1 +>Tree1 : Tree1 + +let tree2: Tree2; +>tree2 : Tree2 +>Tree2 : Tree2 + +tree1 = tree2; +>tree1 = tree2 : Tree2 +>tree1 : Tree1 +>tree2 : Tree2 + +tree2 = tree1; +>tree2 = tree1 : Tree1 +>tree2 : Tree2 +>tree1 : Tree1 + diff --git a/tests/baselines/reference/stringIncludes.symbols b/tests/baselines/reference/stringIncludes.symbols index a2c8eadfe5f..0ca53dbb837 100644 --- a/tests/baselines/reference/stringIncludes.symbols +++ b/tests/baselines/reference/stringIncludes.symbols @@ -5,11 +5,11 @@ var includes: boolean; includes = "abcde".includes("cd"); >includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) ->"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1586, 37)) ->includes : Symbol(String.includes, Decl(lib.d.ts, 1586, 37)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) includes = "abcde".includes("cd", 2); >includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) ->"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1586, 37)) ->includes : Symbol(String.includes, Decl(lib.d.ts, 1586, 37)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index e6cba35be25..1f4ee3debed 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,9 +22,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. Index signatures are incompatible. - Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. + Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -160,9 +160,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. +!!! error TS2322: Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt index 13d5adcf1f5..faef7905453 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt @@ -4,11 +4,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(24,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(31,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(32,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. Index signatures are incompatible. - Type 'typeof A | typeof B' is not assignable to type 'A'. - Type 'typeof A' is not assignable to type 'A'. - Property 'foo' is missing in type 'typeof A'. + Type 'typeof A' is not assignable to type 'A'. + Property 'foo' is missing in type 'typeof A'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts (7 errors) ==== @@ -61,11 +60,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: A } = { ~ -!!! error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +!!! error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'typeof A | typeof B' is not assignable to type 'A'. -!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. -!!! error TS2322: Property 'foo' is missing in type 'typeof A'. +!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. +!!! error TS2322: Property 'foo' is missing in type 'typeof A'. a: A, b: B } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index e43382766ac..b72993e7bea 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -331,14 +331,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : (((x: number) => number[]) | ((x: T) => T[]))[] ->[r1arg2, r1arg1] : (((x: number) => number[]) | ((x: T) => T[]))[] +>r1a : ((x: T) => T[])[] +>[r1arg2, r1arg1] : ((x: T) => T[])[] >r1arg2 : (x: number) => number[] >r1arg1 : (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : (((x: T) => T[]) | ((x: number) => number[]))[] ->[r1arg1, r1arg2] : (((x: T) => T[]) | ((x: number) => number[]))[] +>r1b : ((x: T) => T[])[] +>[r1arg1, r1arg2] : ((x: T) => T[])[] >r1arg1 : (x: T) => T[] >r1arg2 : (x: number) => number[] @@ -365,14 +365,14 @@ var r2 = foo2(r2arg1); >r2arg1 : (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : (((x: T) => string[]) | ((x: number) => string[]))[] ->[r2arg1, r2arg2] : (((x: T) => string[]) | ((x: number) => string[]))[] +>r2a : ((x: T) => string[])[] +>[r2arg1, r2arg2] : ((x: T) => string[])[] >r2arg1 : (x: T) => string[] >r2arg2 : (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : (((x: number) => string[]) | ((x: T) => string[]))[] ->[r2arg2, r2arg1] : (((x: number) => string[]) | ((x: T) => string[]))[] +>r2b : ((x: number) => string[])[] +>[r2arg2, r2arg1] : ((x: number) => string[])[] >r2arg2 : (x: number) => string[] >r2arg1 : (x: T) => string[] @@ -396,14 +396,14 @@ var r3 = foo3(r3arg1); >r3arg1 : (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : (((x: T) => T) | ((x: number) => void))[] ->[r3arg1, r3arg2] : (((x: T) => T) | ((x: number) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg1, r3arg2] : ((x: T) => T)[] >r3arg1 : (x: T) => T >r3arg2 : (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : (((x: number) => void) | ((x: T) => T))[] ->[r3arg2, r3arg1] : (((x: number) => void) | ((x: T) => T))[] +>r3b : ((x: number) => void)[] +>[r3arg2, r3arg1] : ((x: number) => void)[] >r3arg2 : (x: number) => void >r3arg1 : (x: T) => T @@ -432,14 +432,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] ->[r4arg1, r4arg2] : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] +>r4a : ((x: T, y: U) => T)[] +>[r4arg1, r4arg2] : ((x: T, y: U) => T)[] >r4arg1 : (x: T, y: U) => T >r4arg2 : (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] ->[r4arg2, r4arg1] : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] +>r4b : ((x: T, y: U) => T)[] +>[r4arg2, r4arg1] : ((x: T, y: U) => T)[] >r4arg2 : (x: string, y: number) => string >r4arg1 : (x: T, y: U) => T @@ -470,14 +470,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>r5a : ((x: (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] +>r5b : ((x: (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -514,14 +514,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -564,14 +564,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] ->[r7arg1, r7arg2] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>r7a : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] ->[r7arg2, r7arg1] : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] +>r7b : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -622,14 +622,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r8arg1, r8arg2] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] ->[r8arg2, r8arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] +>r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U @@ -681,14 +681,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r9arg1, r9arg2] : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r9a : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg1, r9arg2] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] ->[r9arg2, r9arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] +>r9b : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg2, r9arg1] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U @@ -719,14 +719,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] +>r10a : ((...x: T[]) => T)[] +>[r10arg1, r10arg2] : ((...x: T[]) => T)[] >r10arg1 : (...x: T[]) => T >r10arg2 : (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] ->[r10arg2, r10arg1] : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] +>r10b : ((...x: T[]) => T)[] +>[r10arg2, r10arg1] : ((...x: T[]) => T)[] >r10arg2 : (...x: Derived[]) => Derived >r10arg1 : (...x: T[]) => T @@ -760,14 +760,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : ((x: T, y: T) => T)[] +>[r11arg1, r11arg2] : ((x: T, y: T) => T)[] >r11arg1 : (x: T, y: T) => T >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r11arg2, r11arg1] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r11b : ((x: T, y: T) => T)[] +>[r11arg2, r11arg1] : ((x: T, y: T) => T)[] >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : (x: T, y: T) => T @@ -808,14 +808,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : ((x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : ((x: Base[], y: T) => Derived[])[] >r12arg1 : (x: Base[], y: T) => Derived[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] +>r12b : ((x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : ((x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : (x: Base[], y: T) => Derived[] @@ -853,14 +853,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] +>r13a : ((x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : ((x: Base[], y: T) => T)[] >r13arg1 : (x: Base[], y: T) => T >r13arg2 : (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] +>r13b : ((x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : ((x: Base[], y: T) => T)[] >r13arg2 : (x: Base[], y: Derived[]) => Derived[] >r13arg1 : (x: Base[], y: T) => T @@ -894,14 +894,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>r14a : ((x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : ((x: { a: T; b: T; }) => T)[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] +>r14b : ((x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : ((x: { a: T; b: T; }) => T)[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 0d3a84ac99c..2d4c6e9fda5 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -219,8 +219,8 @@ module Errors { >null : null var r1a = [(x: number) => [''], (x: T) => null]; ->r1a : (((x: number) => string[]) | ((x: T) => U[]))[] ->[(x: number) => [''], (x: T) => null] : (((x: number) => string[]) | ((x: T) => U[]))[] +>r1a : ((x: T) => U[])[] +>[(x: number) => [''], (x: T) => null] : ((x: T) => U[])[] >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] @@ -235,8 +235,8 @@ module Errors { >null : null var r1b = [(x: T) => null, (x: number) => ['']]; ->r1b : (((x: T) => U[]) | ((x: number) => string[]))[] ->[(x: T) => null, (x: number) => ['']] : (((x: T) => U[]) | ((x: number) => string[]))[] +>r1b : ((x: T) => U[])[] +>[(x: T) => null, (x: number) => ['']] : ((x: T) => U[])[] >(x: T) => null : (x: T) => U[] >T : T >U : U @@ -291,14 +291,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] ->[r2arg2, r2arg] : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] +>r2a : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] ->[r2arg, r2arg2] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>r2b : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 @@ -387,14 +387,14 @@ module Errors { >r4arg : (...x: T[]) => T var r4a = [r4arg2, r4arg]; ->r4a : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] ->[r4arg2, r4arg] : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] +>r4a : ((...x: T[]) => T)[] +>[r4arg2, r4arg] : ((...x: T[]) => T)[] >r4arg2 : (...x: Base[]) => Base >r4arg : (...x: T[]) => T var r4b = [r4arg, r4arg2]; ->r4b : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] ->[r4arg, r4arg2] : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] +>r4b : ((...x: T[]) => T)[] +>[r4arg, r4arg2] : ((...x: T[]) => T)[] >r4arg : (...x: T[]) => T >r4arg2 : (...x: Base[]) => Base @@ -430,14 +430,14 @@ module Errors { >r5arg : (x: T, y: T) => T var r5a = [r5arg2, r5arg]; ->r5a : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r5arg2, r5arg] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r5a : ((x: T, y: T) => T)[] +>[r5arg2, r5arg] : ((x: T, y: T) => T)[] >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg : (x: T, y: T) => T var r5b = [r5arg, r5arg2]; ->r5b : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg, r5arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : ((x: T, y: T) => T)[] +>[r5arg, r5arg2] : ((x: T, y: T) => T)[] >r5arg : (x: T, y: T) => T >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -478,14 +478,14 @@ module Errors { >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg]; ->r6a : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg] : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : ((x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg] : ((x: Base[], y: Base[]) => T)[] >r6arg2 : (x: Base[], y: Base[]) => T >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg, r6arg2]; ->r6b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] ->[r6arg, r6arg2] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] +>r6b : ((x: Base[], y: Base[]) => T)[] +>[r6arg, r6arg2] : ((x: Base[], y: Base[]) => T)[] >r6arg : (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : (x: Base[], y: Base[]) => T @@ -517,14 +517,14 @@ module Errors { >r7arg : (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg]; ->r7a : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] +>r7a : ((x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg] : ((x: { a: T; b: T; }) => T)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg : (x: { a: T; b: T; }) => T var r7b = [r7arg, r7arg2]; ->r7b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] ->[r7arg, r7arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] +>r7b : ((x: { a: T; b: T; }) => T)[] +>[r7arg, r7arg2] : ((x: { a: T; b: T; }) => T)[] >r7arg : (x: { a: T; b: T; }) => T >r7arg2 : (x: { a: string; b: number; }) => number @@ -547,14 +547,14 @@ module Errors { >r7arg3 : (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] +>r7d : ((x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : ((x: { a: string; b: number; }) => number)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg3 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] +>r7e : ((x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : ((x: { a: T; b: T; }) => number)[] >r7arg3 : (x: { a: T; b: T; }) => number >r7arg2 : (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index 830f065f556..f490f787878 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -317,14 +317,14 @@ var r3 = foo3(r3arg); >r3arg : (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : (((x: T) => T) | ((x: T) => void))[] ->[r3arg, r3arg2] : (((x: T) => T) | ((x: T) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg, r3arg2] : ((x: T) => T)[] >r3arg : (x: T) => T >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : (((x: T) => void) | ((x: T) => T))[] ->[r3arg2, r3arg] : (((x: T) => void) | ((x: T) => T))[] +>r3b : ((x: T) => void)[] +>[r3arg2, r3arg] : ((x: T) => void)[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -447,14 +447,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg] : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : ((x: (arg: T) => Derived) => T)[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T @@ -498,14 +498,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -543,14 +543,14 @@ var r15 = foo15(r15arg); >r15arg : (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] +>r15a : ((x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : ((x: { a: U; b: V; }) => U[])[] >r15arg : (x: { a: U; b: V; }) => U[] >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] +>r15b : ((x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : ((x: { a: T; b: T; }) => T[])[] >r15arg2 : (x: { a: T; b: T; }) => T[] >r15arg : (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index f00ad0332ca..c66d6055558 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -326,14 +326,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : new (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : ((new (x: number) => number[]) | (new (x: T) => T[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => number[]) | (new (x: T) => T[]))[] +>r1a : (new (x: T) => T[])[] +>[r1arg2, r1arg1] : (new (x: T) => T[])[] >r1arg2 : new (x: number) => number[] >r1arg1 : new (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : ((new (x: T) => T[]) | (new (x: number) => number[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => T[]) | (new (x: number) => number[]))[] +>r1b : (new (x: T) => T[])[] +>[r1arg1, r1arg2] : (new (x: T) => T[])[] >r1arg1 : new (x: T) => T[] >r1arg2 : new (x: number) => number[] @@ -354,14 +354,14 @@ var r2 = foo2(r2arg1); >r2arg1 : new (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : ((new (x: T) => string[]) | (new (x: number) => string[]))[] ->[r2arg1, r2arg2] : ((new (x: T) => string[]) | (new (x: number) => string[]))[] +>r2a : (new (x: T) => string[])[] +>[r2arg1, r2arg2] : (new (x: T) => string[])[] >r2arg1 : new (x: T) => string[] >r2arg2 : new (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : ((new (x: number) => string[]) | (new (x: T) => string[]))[] ->[r2arg2, r2arg1] : ((new (x: number) => string[]) | (new (x: T) => string[]))[] +>r2b : (new (x: number) => string[])[] +>[r2arg2, r2arg1] : (new (x: number) => string[])[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (x: T) => string[] @@ -383,14 +383,14 @@ var r3 = foo3(r3arg1); >r3arg1 : new (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: number) => void))[] ->[r3arg1, r3arg2] : ((new (x: T) => T) | (new (x: number) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg1, r3arg2] : (new (x: T) => T)[] >r3arg1 : new (x: T) => T >r3arg2 : new (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : ((new (x: number) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg1] : ((new (x: number) => void) | (new (x: T) => T))[] +>r3b : (new (x: number) => void)[] +>[r3arg2, r3arg1] : (new (x: number) => void)[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -416,14 +416,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : new (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] ->[r4arg1, r4arg2] : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] +>r4a : (new (x: T, y: U) => T)[] +>[r4arg1, r4arg2] : (new (x: T, y: U) => T)[] >r4arg1 : new (x: T, y: U) => T >r4arg2 : new (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] ->[r4arg2, r4arg1] : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] +>r4b : (new (x: T, y: U) => T)[] +>[r4arg2, r4arg1] : (new (x: T, y: U) => T)[] >r4arg2 : new (x: string, y: number) => string >r4arg1 : new (x: T, y: U) => T @@ -449,14 +449,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : new (x: new (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] +>r5a : (new (x: new (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : (new (x: new (arg: T) => U) => T)[] >r5arg1 : new (x: new (arg: T) => U) => T >r5arg2 : new (x: new (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] +>r5b : (new (x: new (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : (new (x: new (arg: T) => U) => T)[] >r5arg2 : new (x: new (arg: string) => number) => string >r5arg1 : new (x: new (arg: T) => U) => T @@ -487,14 +487,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : new (x: new (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg1 : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : (new (x: new (arg: T) => U) => T)[] >r6arg2 : new (x: new (arg: Base) => Derived) => Base >r6arg1 : new (x: new (arg: T) => U) => T @@ -529,14 +529,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] ->[r7arg1, r7arg2] : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] +>r7a : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg1, r7arg2] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] ->[r7arg2, r7arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] +>r7b : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg2, r7arg1] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U @@ -579,14 +579,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] ->[r8arg1, r8arg2] : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>r8a : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg1, r8arg2] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] ->[r8arg2, r8arg1] : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] +>r8b : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg2, r8arg1] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U @@ -662,14 +662,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : new (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] +>r10a : (new (...x: T[]) => T)[] +>[r10arg1, r10arg2] : (new (...x: T[]) => T)[] >r10arg1 : new (...x: T[]) => T >r10arg2 : new (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] ->[r10arg2, r10arg1] : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] +>r10b : (new (...x: T[]) => T)[] +>[r10arg2, r10arg1] : (new (...x: T[]) => T)[] >r10arg2 : new (...x: Derived[]) => Derived >r10arg1 : new (...x: T[]) => T @@ -699,14 +699,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : new (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : (new (x: T, y: T) => T)[] +>[r11arg1, r11arg2] : (new (x: T, y: T) => T)[] >r11arg1 : new (x: T, y: T) => T >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r11arg2, r11arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r11b : (new (x: T, y: T) => T)[] +>[r11arg2, r11arg1] : (new (x: T, y: T) => T)[] >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : new (x: T, y: T) => T @@ -741,14 +741,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : new (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : (new (x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : (new (x: Base[], y: T) => Derived[])[] >r12arg1 : new (x: Base[], y: T) => Derived[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] +>r12b : (new (x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : (new (x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : new (x: Base[], y: T) => Derived[] @@ -782,14 +782,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : new (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] +>r13a : (new (x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : (new (x: Base[], y: T) => T)[] >r13arg1 : new (x: Base[], y: T) => T >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] +>r13b : (new (x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : (new (x: Base[], y: T) => T)[] >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] >r13arg1 : new (x: Base[], y: T) => T @@ -817,14 +817,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>r14a : (new (x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : (new (x: { a: T; b: T; }) => T)[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] +>r14b : (new (x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : (new (x: { a: T; b: T; }) => T)[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index b7c90d8697e..741db4f4ba6 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -224,14 +224,14 @@ module Errors { >r1arg1 : new (x: T) => U[] var r1a = [r1arg2, r1arg1]; ->r1a : ((new (x: number) => string[]) | (new (x: T) => U[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => string[]) | (new (x: T) => U[]))[] +>r1a : (new (x: T) => U[])[] +>[r1arg2, r1arg1] : (new (x: T) => U[])[] >r1arg2 : new (x: number) => string[] >r1arg1 : new (x: T) => U[] var r1b = [r1arg1, r1arg2]; ->r1b : ((new (x: T) => U[]) | (new (x: number) => string[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => U[]) | (new (x: number) => string[]))[] +>r1b : (new (x: T) => U[])[] +>[r1arg1, r1arg2] : (new (x: T) => U[])[] >r1arg1 : new (x: T) => U[] >r1arg2 : new (x: number) => string[] @@ -268,14 +268,14 @@ module Errors { >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2a = [r2arg2, r2arg1]; ->r2a : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] ->[r2arg2, r2arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] +>r2a : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg2, r2arg1] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2b = [r2arg1, r2arg2]; ->r2b : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] ->[r2arg1, r2arg2] : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] +>r2b : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg1, r2arg2] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 @@ -350,14 +350,14 @@ module Errors { >r4arg1 : new (...x: T[]) => T var r4a = [r4arg2, r4arg1]; ->r4a : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] ->[r4arg2, r4arg1] : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] +>r4a : (new (...x: T[]) => T)[] +>[r4arg2, r4arg1] : (new (...x: T[]) => T)[] >r4arg2 : new (...x: Base[]) => Base >r4arg1 : new (...x: T[]) => T var r4b = [r4arg1, r4arg2]; ->r4b : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] ->[r4arg1, r4arg2] : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] +>r4b : (new (...x: T[]) => T)[] +>[r4arg1, r4arg2] : (new (...x: T[]) => T)[] >r4arg1 : new (...x: T[]) => T >r4arg2 : new (...x: Base[]) => Base @@ -387,14 +387,14 @@ module Errors { >r5arg1 : new (x: T, y: T) => T var r5a = [r5arg2, r5arg1]; ->r5a : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r5arg2, r5arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r5a : (new (x: T, y: T) => T)[] +>[r5arg2, r5arg1] : (new (x: T, y: T) => T)[] >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg1 : new (x: T, y: T) => T var r5b = [r5arg1, r5arg2]; ->r5b : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg1, r5arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : (new (x: T, y: T) => T)[] +>[r5arg1, r5arg2] : (new (x: T, y: T) => T)[] >r5arg1 : new (x: T, y: T) => T >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -429,14 +429,14 @@ module Errors { >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg1]; ->r6a : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg1] : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : (new (x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg1] : (new (x: Base[], y: Base[]) => T)[] >r6arg2 : new (x: Base[], y: Base[]) => T >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg1, r6arg2]; ->r6b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] ->[r6arg1, r6arg2] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] +>r6b : (new (x: Base[], y: Base[]) => T)[] +>[r6arg1, r6arg2] : (new (x: Base[], y: Base[]) => T)[] >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : new (x: Base[], y: Base[]) => T @@ -463,14 +463,14 @@ module Errors { >r7arg1 : new (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg1]; ->r7a : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg1] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] +>r7a : (new (x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg1] : (new (x: { a: T; b: T; }) => T)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg1 : new (x: { a: T; b: T; }) => T var r7b = [r7arg1, r7arg2]; ->r7b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg1, r7arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] +>r7b : (new (x: { a: T; b: T; }) => T)[] +>[r7arg1, r7arg2] : (new (x: { a: T; b: T; }) => T)[] >r7arg1 : new (x: { a: T; b: T; }) => T >r7arg2 : new (x: { a: string; b: number; }) => number @@ -491,14 +491,14 @@ module Errors { >r7arg3 : new (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] +>r7d : (new (x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : (new (x: { a: string; b: number; }) => number)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg3 : new (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] +>r7e : (new (x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : (new (x: { a: T; b: T; }) => number)[] >r7arg3 : new (x: { a: T; b: T; }) => number >r7arg2 : new (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 328dadad41c..932adcb7368 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -301,14 +301,14 @@ var r3 = foo3(r3arg); >r3arg : new (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: T) => void))[] ->[r3arg, r3arg2] : ((new (x: T) => T) | (new (x: T) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg, r3arg2] : (new (x: T) => T)[] >r3arg : new (x: T) => T >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : ((new (x: T) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg] : ((new (x: T) => void) | (new (x: T) => T))[] +>r3b : (new (x: T) => void)[] +>[r3arg2, r3arg] : (new (x: T) => void)[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -415,14 +415,14 @@ var r6 = foo6(r6arg); >r6arg : new (x: new (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg] : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : (new (x: new (arg: T) => Derived) => T)[] >r6arg2 : new (x: new (arg: T) => Derived) => T >r6arg : new (x: new (arg: T) => U) => T @@ -460,14 +460,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -499,14 +499,14 @@ var r15 = foo15(r15arg); >r15arg : new (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] +>r15a : (new (x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : (new (x: { a: U; b: V; }) => U[])[] >r15arg : new (x: { a: U; b: V; }) => U[] >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] +>r15b : (new (x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : (new (x: { a: T; b: T; }) => T[])[] >r15arg2 : new (x: { a: T; b: T; }) => T[] >r15arg : new (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types index 0d55d78e266..815f2d60740 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types @@ -85,8 +85,8 @@ var b = { Foo: null }; >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived; } @@ -156,8 +156,8 @@ module TwoLevels { >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived2; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived2; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived2; } diff --git a/tests/baselines/reference/superSymbolIndexedAccess1.symbols b/tests/baselines/reference/superSymbolIndexedAccess1.symbols index 818d0ac52af..416ac465e24 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess1.symbols +++ b/tests/baselines/reference/superSymbolIndexedAccess1.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts === var symbol = Symbol.for('myThing'); >symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) class Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35)) diff --git a/tests/baselines/reference/superSymbolIndexedAccess2.symbols b/tests/baselines/reference/superSymbolIndexedAccess2.symbols index 3865b920647..726abb3fdc5 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess2.symbols +++ b/tests/baselines/reference/superSymbolIndexedAccess2.symbols @@ -4,9 +4,9 @@ class Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) [Symbol.isConcatSpreadable]() { ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) return 0; } @@ -17,14 +17,14 @@ class Bar extends Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) [Symbol.isConcatSpreadable]() { ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) return super[Symbol.isConcatSpreadable](); >super : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } } diff --git a/tests/baselines/reference/switchStatements.errors.txt b/tests/baselines/reference/switchStatements.errors.txt index aa5b796e252..c99b0eba909 100644 --- a/tests/baselines/reference/switchStatements.errors.txt +++ b/tests/baselines/reference/switchStatements.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,10): error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. +tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,20): error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. Object literal may only specify known properties, and 'name' does not exist in type 'C'. @@ -38,7 +38,7 @@ tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,10): switch (new C()) { case new D(): case { id: 12, name: '' }: - ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type 'C'. case new C(): diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index 9fae9d57c4f..9a7d93c7246 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 5dba2268d26..63602f4fd2c 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index a6019a364e4..850bde66c49 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index e16ec738489..accb92a8c52 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index b2f520351f2..91a5cfdd760 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index 7e9d06cd332..1993e369aea 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index 177180b5bca..84f39f363f1 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index 98cb277ad47..655a91fc88b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index 17bda345253..1436f9b9f69 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index c4b046cc146..f07ebd532fa 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index 58a661412da..0435dc15df2 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 7879d28b02f..7e95754b1eb 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index 17901fb713a..d4f08115a21 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index 4028da455a6..3db0f7012cb 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 07e9b6bae26..62ce887a731 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index d4e79a064a9..c48bd271c87 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index 2a83145da03..56f722c523b 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index 1b4b23e9511..092d766034e 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index 89df72d6543..b5d930b4005 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index 3ee9ed595c2..eae891f2e22 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index b52c4087d71..d03ca9a4c51 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index ad4f0c79523..110067abda5 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.errors.txt b/tests/baselines/reference/symbolProperty21.errors.txt index b9162acc84f..fa9cabc9b61 100644 --- a/tests/baselines/reference/symbolProperty21.errors.txt +++ b/tests/baselines/reference/symbolProperty21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty21.ts(8,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. +tests/cases/conformance/es6/Symbols/symbolProperty21.ts(10,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. @@ -11,14 +11,10 @@ tests/cases/conformance/es6/Symbols/symbolProperty21.ts(8,5): error TS2345: Argu declare function foo(p: I): { t: T; u: U }; foo({ - ~ [Symbol.isConcatSpreadable]: "", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Symbol.toPrimitive]: 0, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [Symbol.unscopables]: true - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - }); - ~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. -!!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. \ No newline at end of file +!!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. + [Symbol.unscopables]: true + }); \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index b62037e32a5..2288537456c 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index da9d07ffeed..152048a95a8 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index 46babb69a87..7a2e443368f 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index 69fe473e17c..306802cdff2 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index cf6ab1f5edb..77b476c6ea3 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index 4e17e561bce..c159cc756d8 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index e3e469764a8..29b66c96f1f 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index 622d1b693e8..129c856b804 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 5aba3b8c104..34bb5ad967f 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 3876, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 3876, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index 7b57003e607..063ae8d3d34 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index 4beb1f6d9e2..64472f3c71a 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 32240efd986..45a56260828 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index 05eeace3b86..98f4a7769b2 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1209, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 3850, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index a4e335cc7d7..fe73fb9f330 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index 249545872b1..eaf5be2a07c 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index 78be14d0862..04b89f43652 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 64452f49c9c..541833d686a 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index d40e0e72724..bbccd2a0f8b 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType11.types b/tests/baselines/reference/symbolType11.types index a7de59a11b7..b251db43301 100644 --- a/tests/baselines/reference/symbolType11.types +++ b/tests/baselines/reference/symbolType11.types @@ -33,7 +33,7 @@ s || 1; >1 : number ({}) || s; ->({}) || s : {} | symbol +>({}) || s : {} >({}) : {} >{} : {} >s : symbol diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 4b61749b898..9a25d9ad152 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt index 6464366d33d..be5c21f1a0b 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -86,7 +86,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt index be8c517d39c..63d04a42b3b 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(63,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -85,7 +85,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index b35249b53f7..42a865e4e28 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types index cd6265de091..613835f3211 100644 --- a/tests/baselines/reference/tsxElementResolution13.types +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -25,4 +25,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any +>10 : number diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types index ef03187d28e..80f9555030f 100644 --- a/tests/baselines/reference/tsxElementResolution14.types +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -20,4 +20,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any +>10 : number diff --git a/tests/baselines/reference/tsxElementResolution9.types b/tests/baselines/reference/tsxElementResolution9.types index 525e4600b2e..6725bd216bd 100644 --- a/tests/baselines/reference/tsxElementResolution9.types +++ b/tests/baselines/reference/tsxElementResolution9.types @@ -67,4 +67,5 @@ var Obj3: Obj3; > : JSX.Element >Obj3 : Obj3 >x : any +>42 : number diff --git a/tests/baselines/reference/tsxEmit1.symbols b/tests/baselines/reference/tsxEmit1.symbols index b7c8cde024a..aaca98ae9db 100644 --- a/tests/baselines/reference/tsxEmit1.symbols +++ b/tests/baselines/reference/tsxEmit1.symbols @@ -52,6 +52,7 @@ var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(tsxEmit1.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >x : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >y : Symbol(unknown) var openClosed1 =
; @@ -69,6 +70,7 @@ var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(tsxEmit1.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var openClosed4 =
{p < p}
; @@ -146,6 +148,7 @@ var whitespace1 =
; var whitespace2 =
{p}
; >whitespace2 : Symbol(whitespace2, Decl(tsxEmit1.tsx, 35, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var whitespace3 =
@@ -153,6 +156,8 @@ var whitespace3 =
>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types index 667ec113337..a427270354e 100644 --- a/tests/baselines/reference/tsxEmit1.types +++ b/tests/baselines/reference/tsxEmit1.types @@ -45,6 +45,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any +>0 : number >y : any var selfClosed6 =
; @@ -52,6 +53,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any +>"1" : string >y : any var selfClosed7 =
; diff --git a/tests/baselines/reference/tsxEmit2.symbols b/tests/baselines/reference/tsxEmit2.symbols index fd568953493..5eefc31710d 100644 --- a/tests/baselines/reference/tsxEmit2.symbols +++ b/tests/baselines/reference/tsxEmit2.symbols @@ -21,29 +21,38 @@ var p1, p2, p3; var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(tsxEmit2.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(tsxEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(tsxEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(tsxEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(tsxEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >y : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.symbols b/tests/baselines/reference/tsxExternalModuleEmit2.symbols index 137e9befa56..6f8d3d76cd2 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.symbols +++ b/tests/baselines/reference/tsxExternalModuleEmit2.symbols @@ -20,6 +20,7 @@ declare var Foo, React; ; >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) >handler : Symbol(unknown) +>Main : Symbol(Main, Decl(app.tsx, 0, 6)) >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) // Should see mod_1['default'] in emit here diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index f1799e5bb77..260bd9cd228 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -69,6 +69,6 @@ var SomeClass = (function () { }; return SomeClass; })(); -var whitespace1 = React.createElement("div", null); -var whitespace2 = React.createElement("div", null, p); +var whitespace1 = React.createElement("div", null, " "); +var whitespace2 = React.createElement("div", null, " ", p, " "); var whitespace3 = React.createElement("div", null, p); diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index 665c6a0271f..4149142dd82 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -54,6 +54,7 @@ var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 15, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >y : Symbol(unknown) >b : Symbol(unknown) @@ -72,6 +73,7 @@ var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed4 =
{p < p}
; @@ -150,6 +152,7 @@ var whitespace1 =
; var whitespace2 =
{p}
; >whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 36, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace3 =
@@ -157,6 +160,8 @@ var whitespace3 =
>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index 0b6e03c5742..e180d2b6b70 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -47,6 +47,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any +>0 : number >y : any var selfClosed6 =
; @@ -54,6 +55,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any +>"1" : string >y : any var selfClosed7 =
; diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols index 7805a16363e..049fdb1819b 100644 --- a/tests/baselines/reference/tsxReactEmit2.symbols +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -23,29 +23,38 @@ var p1, p2, p3; var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >y : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js index 1a6ba037230..23910548534 100644 --- a/tests/baselines/reference/tsxReactEmit3.js +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -8,4 +8,4 @@ declare var Foo, Bar, baz; q s ; //// [tsxReactEmit3.js] -React.createElement(Foo, null, React.createElement(Bar, null, "q "), React.createElement(Bar, null), "s ", React.createElement(Bar, null), React.createElement(Bar, null)); +React.createElement(Foo, null, " ", React.createElement(Bar, null, " q "), " ", React.createElement(Bar, null), " s ", React.createElement(Bar, null), React.createElement(Bar, null)); diff --git a/tests/baselines/reference/tsxReactEmit5.js b/tests/baselines/reference/tsxReactEmit5.js new file mode 100644 index 00000000000..f6a7eeb72a1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit5.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [test.d.ts] +export var React; + +//// [react-consumer.tsx] +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; + + +//// [file.js] +//// [react-consumer.js] +var test_1 = require("./test"); +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 = test_1.React.createElement("div", test_1.React.__spread({x: ''}, foo, {y: ''})); diff --git a/tests/baselines/reference/tsxReactEmit5.symbols b/tests/baselines/reference/tsxReactEmit5.symbols new file mode 100644 index 00000000000..388e717957f --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : Symbol(React, Decl(test.d.ts, 0, 10)) + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : Symbol(React, Decl(react-consumer.tsx, 0, 8)) + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3)) + +var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 4, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxReactEmit5.types b/tests/baselines/reference/tsxReactEmit5.types new file mode 100644 index 00000000000..fb1c6594f30 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : any + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : any + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : any + +var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any + diff --git a/tests/baselines/reference/tsxReactEmit6.js b/tests/baselines/reference/tsxReactEmit6.js new file mode 100644 index 00000000000..d20ef7051e0 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit6.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [react-consumer.tsx] +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} + + +//// [file.js] +//// [react-consumer.js] +var M; +(function (M) { +})(M || (M = {})); +var M; +(function (M) { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 = M.React.createElement("div", M.React.__spread({x: ''}, foo, {y: ''})); +})(M || (M = {})); diff --git a/tests/baselines/reference/tsxReactEmit6.symbols b/tests/baselines/reference/tsxReactEmit6.symbols new file mode 100644 index 00000000000..0302cef3e8d --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + export var React: any; +>React : Symbol(React, Decl(react-consumer.tsx, 1, 11)) +} + +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4)) + + var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 8, 4)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) +} + diff --git a/tests/baselines/reference/tsxReactEmit6.types b/tests/baselines/reference/tsxReactEmit6.types new file mode 100644 index 00000000000..1b16b84fcc7 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : typeof M + + export var React: any; +>React : any +} + +namespace M { +>M : typeof M + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : any + + var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any +} + diff --git a/tests/baselines/reference/tsxReactEmitEntities.js b/tests/baselines/reference/tsxReactEmitEntities.js new file mode 100644 index 00000000000..7517c85fc73 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.js @@ -0,0 +1,14 @@ +//// [tsxReactEmitEntities.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +
Dot goes here: · ¬AnEntity;
; + + +//// [tsxReactEmitEntities.js] +React.createElement("div", null, "Dot goes here: · ¬AnEntity; "); diff --git a/tests/baselines/reference/tsxReactEmitEntities.symbols b/tests/baselines/reference/tsxReactEmitEntities.symbols new file mode 100644 index 00000000000..7de35241a3a --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsx/tsxReactEmitEntities.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitEntities.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitEntities.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitEntities.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitEntities.tsx, 6, 11)) + +
Dot goes here: · ¬AnEntity;
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) + diff --git a/tests/baselines/reference/tsxReactEmitEntities.types b/tests/baselines/reference/tsxReactEmitEntities.types new file mode 100644 index 00000000000..e1c9cb6e6bf --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/jsx/tsxReactEmitEntities.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +
Dot goes here: · ¬AnEntity;
; +>
Dot goes here: · ¬AnEntity;
: JSX.Element +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index a124ce73312..a1b5894106f 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -57,17 +57,17 @@ var p = 0; // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT var p = 0; // Emit " " -React.createElement("div", null); +React.createElement("div", null, " "); // Emit " ", p, " " -React.createElement("div", null, p); +React.createElement("div", null, " ", p, " "); // Emit only p React.createElement("div", null, p); // Emit only p React.createElement("div", null, p); // Emit " 3" -React.createElement("div", null, "3"); +React.createElement("div", null, " 3"); // Emit " 3 " -React.createElement("div", null, "3 "); +React.createElement("div", null, " 3 "); // Emit "3" React.createElement("div", null, "3"); // Emit no args diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index 96b902372b7..3aa3f0d0f8a 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -29,6 +29,7 @@ var p = 0; // Emit " ", p, " "
{p}
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit only p @@ -36,6 +37,8 @@ var p = 0; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) @@ -44,6 +47,8 @@ var p = 0; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index 603dc4ca6c1..4622aef1991 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -32,7 +32,7 @@ var p = 0;
{p}
; >
{p}
: JSX.Element >div : any ->p : any +>p : number >div : any // Emit only p @@ -41,7 +41,7 @@ var p = 0; >div : any {p} ->p : any +>p : number
; >div : any @@ -52,7 +52,7 @@ var p = 0; >div : any {p} ->p : any +>p : number
; >div : any diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.js b/tests/baselines/reference/tsxReactEmitWhitespace2.js new file mode 100644 index 00000000000..091a193cdc5 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.js @@ -0,0 +1,25 @@ +//// [tsxReactEmitWhitespace2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// Emit ' word' in the last string +
word code word
; +// Same here +
code word
; +// And here +
word
; + + + +//// [tsxReactEmitWhitespace2.js] +// Emit ' word' in the last string +React.createElement("div", null, "word ", React.createElement("code", null, "code"), " word"); +// Same here +React.createElement("div", null, React.createElement("code", null, "code"), " word"); +// And here +React.createElement("div", null, React.createElement("code", null), " word"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.symbols b/tests/baselines/reference/tsxReactEmitWhitespace2.symbols new file mode 100644 index 00000000000..44ff4cba292 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitWhitespace2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitWhitespace2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitWhitespace2.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitWhitespace2.tsx, 6, 11)) + +// Emit ' word' in the last string +
word code word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + +// Same here +
code word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + +// And here +
word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.types b/tests/baselines/reference/tsxReactEmitWhitespace2.types new file mode 100644 index 00000000000..7287e59b9b1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +// Emit ' word' in the last string +
word code word
; +>
word code word
: JSX.Element +>div : any +>code : JSX.Element +>code : any +>code : any +>div : any + +// Same here +
code word
; +>
code word
: JSX.Element +>div : any +>code : JSX.Element +>code : any +>code : any +>div : any + +// And here +
word
; +>
word
: JSX.Element +>div : any +> : JSX.Element +>code : any +>div : any + + diff --git a/tests/baselines/reference/tsxTypeErrors.symbols b/tests/baselines/reference/tsxTypeErrors.symbols index bfe0c568640..94399b95d1f 100644 --- a/tests/baselines/reference/tsxTypeErrors.symbols +++ b/tests/baselines/reference/tsxTypeErrors.symbols @@ -18,6 +18,7 @@ var thing = { oops: 100 }; var a3 =
>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 9, 3)) >id : Symbol(unknown) +>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3)) // Mistyped html name (error) var e1 = diff --git a/tests/baselines/reference/tsxTypeErrors.types b/tests/baselines/reference/tsxTypeErrors.types index 92c7148b314..303c7695dbf 100644 --- a/tests/baselines/reference/tsxTypeErrors.types +++ b/tests/baselines/reference/tsxTypeErrors.types @@ -26,7 +26,7 @@ var a3 =
>
: any >div : any >id : any ->thing : any +>thing : { oops: number; } // Mistyped html name (error) var e1 = diff --git a/tests/baselines/reference/typeArgInference2.errors.txt b/tests/baselines/reference/typeArgInference2.errors.txt index 71d2a13f4a1..b7201fd1033 100644 --- a/tests/baselines/reference/typeArgInference2.errors.txt +++ b/tests/baselines/reference/typeArgInference2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/compiler/typeArgInference2.ts(12,52): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. @@ -16,7 +16,7 @@ tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argumen var z4 = foo({ name: "abc" }); // { name: string } var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error - ~~~ + ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. !!! error TS2453: Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.errors.txt b/tests/baselines/reference/typeArgumentInference.errors.txt index 669ebadd28a..51cf4ccf7d2 100644 --- a/tests/baselines/reference/typeArgumentInference.errors.txt +++ b/tests/baselines/reference/typeArgumentInference.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -93,13 +93,13 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,66 z?: Date; } var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols index 4acd2dc5323..28cb344da6e 100644 --- a/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols +++ b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols @@ -3,7 +3,7 @@ function method(iterable: Iterable): T { >method : Symbol(method, Decl(typeArgumentInferenceApparentType1.ts, 0, 0)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) >iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType1.ts, 0, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols index 6f4ae7b0f71..2287b1db082 100644 --- a/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols +++ b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols @@ -3,14 +3,14 @@ function method(iterable: Iterable): T { >method : Symbol(method, Decl(typeArgumentInferenceApparentType2.ts, 0, 0)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) >iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType2.ts, 0, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) function inner>() { >inner : Symbol(inner, Decl(typeArgumentInferenceApparentType2.ts, 0, 46)) >U : Symbol(U, Decl(typeArgumentInferenceApparentType2.ts, 1, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1698, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) var u: U; diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index 305eee1c941..d058426b9c9 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -12,12 +12,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,56): error TS2304: Cannot find name 'window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -163,17 +163,17 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct !!! error TS2304: Cannot find name 'Window'. } var a9e = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS2304: Cannot find name 'window'. + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. - ~~~~~~ -!!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 6b81cd6f232..0c1e8cc4e97 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -17,12 +17,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,65): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,52): error TS2304: Cannot find name 'window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,62): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,70): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -145,17 +145,17 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst !!! error TS2304: Cannot find name 'Window'. } var a9e = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS2304: Cannot find name 'window'. + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. - ~~~~~~ -!!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js new file mode 100644 index 00000000000..e23af7afab6 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js @@ -0,0 +1,13 @@ +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts] +type TreeNode = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNode[]; +nodes.map(n => n.name); + + +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js] +var nodes; +nodes.map(function (n) { return n.name; }); diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols new file mode 100644 index 00000000000..08b61492a54 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts === +type TreeNode = { +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 1, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) +} + +var nodes: TreeNode[]; +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) + +nodes.map(n => n.name); +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) +>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) +>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types new file mode 100644 index 00000000000..ea821607211 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts === +type TreeNode = { +>TreeNode : { name: string; parent: TreeNode; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +var nodes: TreeNode[]; +>nodes : { name: string; parent: TreeNode; }[] +>TreeNode : { name: string; parent: TreeNode; } + +nodes.map(n => n.name); +>nodes.map(n => n.name) : string[] +>nodes.map : (callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[] +>nodes : { name: string; parent: TreeNode; }[] +>map : (callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[] +>n => n.name : (n: { name: string; parent: TreeNode; }) => string +>n : { name: string; parent: TreeNode; } +>n.name : string +>n : { name: string; parent: TreeNode; } +>name : string + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js new file mode 100644 index 00000000000..d8e32e12b55 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js @@ -0,0 +1,18 @@ +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts] +type TreeNode = { + name: string; + parent: TreeNode; +} + +type TreeNodeMiddleman = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNodeMiddleman[]; +nodes.map(n => n.name); + + +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js] +var nodes; +nodes.map(function (n) { return n.name; }); diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols new file mode 100644 index 00000000000..cb2e8e94656 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts === +type TreeNode = { +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 17)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 1, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) +} + +type TreeNodeMiddleman = { +>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 6, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) +} + +var nodes: TreeNodeMiddleman[]; +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) +>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) + +nodes.map(n => n.name); +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) +>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) +>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types new file mode 100644 index 00000000000..d18cf3a2b1d --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts === +type TreeNode = { +>TreeNode : { name: string; parent: TreeNode; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +type TreeNodeMiddleman = { +>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +var nodes: TreeNodeMiddleman[]; +>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[] +>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; } + +nodes.map(n => n.name); +>nodes.map(n => n.name) : string[] +>nodes.map : (callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[] +>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[] +>map : (callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[] +>n => n.name : (n: { name: string; parent: { name: string; parent: TreeNode; }; }) => string +>n : { name: string; parent: { name: string; parent: TreeNode; }; } +>n.name : string +>n : { name: string; parent: { name: string; parent: TreeNode; }; } +>name : string + diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.types b/tests/baselines/reference/typeGuardsInConditionalExpression.types index ef048fb8562..493a8c0a31a 100644 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.types +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.types @@ -363,9 +363,9 @@ function foo12(x: number | string | boolean) { >10 : number >x.toString().length : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string >length : number : ((b = x) // x is number | boolean | string - changed in true branch diff --git a/tests/baselines/reference/typeGuardsInIfStatement.js b/tests/baselines/reference/typeGuardsInIfStatement.js index 820d205bc65..de05a7bf82a 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.js +++ b/tests/baselines/reference/typeGuardsInIfStatement.js @@ -1,9 +1,9 @@ //// [typeGuardsInIfStatement.ts] -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { if (typeof x === "string") { @@ -149,11 +149,11 @@ function foo12(x: number | string | boolean) { } //// [typeGuardsInIfStatement.js] -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x) { if (typeof x === "string") { diff --git a/tests/baselines/reference/typeGuardsInIfStatement.symbols b/tests/baselines/reference/typeGuardsInIfStatement.symbols index d940e10e066..798fe18cf5a 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.symbols +++ b/tests/baselines/reference/typeGuardsInIfStatement.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { >foo : Symbol(foo, Decl(typeGuardsInIfStatement.ts, 0, 0)) diff --git a/tests/baselines/reference/typeGuardsInIfStatement.types b/tests/baselines/reference/typeGuardsInIfStatement.types index e049d318a02..0095a7cc768 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.types +++ b/tests/baselines/reference/typeGuardsInIfStatement.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { >foo : (x: number | string) => number @@ -333,9 +333,9 @@ function foo11(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string ) : ( @@ -348,9 +348,9 @@ function foo11(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string ); } @@ -369,9 +369,9 @@ function foo12(x: number | string | boolean) { return x.toString(); // string | number | boolean - x changed in else branch >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } else { x = 10; diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types index b69c80ff55a..22d390618c1 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types @@ -180,9 +180,9 @@ function foo7(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string // do not change value : (y = x && x.toString()))); // number | boolean | string @@ -192,9 +192,9 @@ function foo7(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } function foo8(x: number | string) { >foo8 : (x: number | string) => number diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types index b2f5401e843..38d9a723d3a 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types @@ -180,9 +180,9 @@ function foo7(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string // do not change value : (y = x && x.toString()))); // number | boolean | string @@ -192,9 +192,9 @@ function foo7(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } function foo8(x: number | string) { >foo8 : (x: number | string) => boolean | number diff --git a/tests/baselines/reference/typeInfer1.errors.txt b/tests/baselines/reference/typeInfer1.errors.txt index 2550bb1fe8d..6f26b2e6054 100644 --- a/tests/baselines/reference/typeInfer1.errors.txt +++ b/tests/baselines/reference/typeInfer1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. +tests/cases/compiler/typeInfer1.ts(12,5): error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. @@ -14,8 +14,8 @@ tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => strin } var yyyyyyyy: ITextWriter2 = { - ~~~~~~~~ + Moo: function() { return "cow"; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. !!! error TS2322: Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. - Moo: function() { return "cow"; } } \ No newline at end of file diff --git a/tests/baselines/reference/typeMatch2.errors.txt b/tests/baselines/reference/typeMatch2.errors.txt index a497551c953..e82439c0ad5 100644 --- a/tests/baselines/reference/typeMatch2.errors.txt +++ b/tests/baselines/reference/typeMatch2.errors.txt @@ -2,9 +2,9 @@ tests/cases/compiler/typeMatch2.ts(3,2): error TS2322: Type '{}' is not assignab Property 'x' is missing in type '{}'. tests/cases/compiler/typeMatch2.ts(4,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. -tests/cases/compiler/typeMatch2.ts(5,2): error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(5,20): error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. -tests/cases/compiler/typeMatch2.ts(6,5): error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(6,17): error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(18,5): error TS2322: Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. @@ -13,7 +13,7 @@ tests/cases/compiler/typeMatch2.ts(22,5): error TS2322: Type '{ f1: number; f2: Types of property 'f2' are incompatible. Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. -tests/cases/compiler/typeMatch2.ts(34,5): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(34,26): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. @@ -31,11 +31,11 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Property 'y' is missing in type '{ x: number; }'. a = { x: 1, y: 2, z: 3 }; - ~ + ~~~~ !!! error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1, z: 3 }; // error - ~ + ~~~~ !!! error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. } @@ -75,7 +75,7 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is a = { x: 1, y: undefined }; a = { x: 1, y: _any }; a = { x: 1, y: _any, z:1 }; - ~ + ~~~ !!! error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1 }; // error diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 27749ed496e..dcba2e51f48 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1450, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2455, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2455, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 1635, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 1635, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2745, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2745, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 1909, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 1909, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3325, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3325, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 2456, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 2456, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3615, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3615, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 2730, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 2730, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3905, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3905, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3003, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3003, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4195, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4195, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 3276, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 3276, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4485, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4485, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 3549, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 3549, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4775, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4775, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 3035, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 3035, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2183, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2183, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1450, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1450, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2181, 42), Decl(lib.d.ts, 2471, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2461, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2471, 44), Decl(lib.d.ts, 2761, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2751, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 3051, 60), Decl(lib.d.ts, 3341, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3331, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3341, 46), Decl(lib.d.ts, 3631, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3621, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3631, 48), Decl(lib.d.ts, 3921, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3911, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3921, 46), Decl(lib.d.ts, 4211, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4201, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4211, 48), Decl(lib.d.ts, 4501, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4491, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4501, 50), Decl(lib.d.ts, 4791, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4781, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2761, 46), Decl(lib.d.ts, 3051, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 3041, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 33ae53f609d..9886982c0f2 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -274,9 +274,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : number >Int8Array.from(obj) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -285,9 +285,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : number >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -296,9 +296,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : number >Int16Array.from(obj) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -307,9 +307,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : number >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -318,9 +318,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : number >Int32Array.from(obj) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -329,9 +329,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : number >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -340,9 +340,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : number >Float32Array.from(obj) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -351,9 +351,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : number >Float64Array.from(obj) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -362,9 +362,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -386,9 +386,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : number >Int8Array.from(obj) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -397,9 +397,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : number >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -408,9 +408,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : number >Int16Array.from(obj) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -419,9 +419,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : number >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -430,9 +430,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : number >Int32Array.from(obj) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -441,9 +441,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : number >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -452,9 +452,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : number >Float32Array.from(obj) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -463,9 +463,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : number >Float64Array.from(obj) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -474,9 +474,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -655,9 +655,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : number >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -667,9 +667,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : number >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -679,9 +679,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : number >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -691,9 +691,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : number >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -703,9 +703,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : number >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -715,9 +715,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : number >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -727,9 +727,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : number >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -739,9 +739,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : number >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -751,9 +751,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -780,9 +780,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : number >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -793,9 +793,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : number >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -806,9 +806,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : number >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -819,9 +819,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : number >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -832,9 +832,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : number >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -845,9 +845,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : number >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -858,9 +858,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : number >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -871,9 +871,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : number >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -884,9 +884,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 31b01c5f76e..7fe233c4490 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -547,7 +547,7 @@ _.flatten([1, [2], [3, [[4]]]]); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number @@ -562,7 +562,7 @@ _.flatten([1, [2], [3, [[4]]]], true); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.types b/tests/baselines/reference/unionTypeFromArrayLiteral.types index 604925eb25f..63aefdd214c 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.types +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.types @@ -83,15 +83,15 @@ var arr6 = [c, d]; // (C | D)[] >d : D var arr7 = [c, d, e]; // (C | D)[] ->arr7 : (C | D | E)[] ->[c, d, e] : (C | D | E)[] +>arr7 : (C | D)[] +>[c, d, e] : (C | D)[] >c : C >d : D >e : E var arr8 = [c, e]; // C[] ->arr8 : (C | E)[] ->[c, e] : (C | E)[] +>arr8 : C[] +>[c, e] : C[] >c : C >e : E diff --git a/tests/baselines/reference/unionTypeReduction.types b/tests/baselines/reference/unionTypeReduction.types index 8ecd9b33fb5..073d690162a 100644 --- a/tests/baselines/reference/unionTypeReduction.types +++ b/tests/baselines/reference/unionTypeReduction.types @@ -25,8 +25,8 @@ var e1: I2 | I3; >I3 : I3 var e2 = i2 || i3; // Type of e2 immediately reduced to I3 ->e2 : I2 | I3 ->i2 || i3 : I2 | I3 +>e2 : I3 +>i2 || i3 : I3 >i2 : I2 >i3 : I3 @@ -38,5 +38,5 @@ var r1 = e1(); // Type of e1 reduced to I3 upon accessing property or signature var r2 = e2(); >r2 : number >e2() : number ->e2 : I2 | I3 +>e2 : I3 diff --git a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types index f609301c19c..caaa02b7b53 100644 --- a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types +++ b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types @@ -39,7 +39,7 @@ var t: Class | Property; >Property : Property t.parent; ->t.parent : Namespace | Module | Class +>t.parent : Namespace | Class >t : Class | Property ->parent : Namespace | Module | Class +>parent : Namespace | Class diff --git a/tests/cases/compiler/commonjsSafeImport.ts b/tests/cases/compiler/commonjsSafeImport.ts new file mode 100644 index 00000000000..ce494ee54ad --- /dev/null +++ b/tests/cases/compiler/commonjsSafeImport.ts @@ -0,0 +1,11 @@ +// @target: ES5 +// @module: commonjs +// @declaration: true +// @filename: 10_lib.ts + +export function Foo() {} + +// @filename: main.ts +import { Foo } from './10_lib'; + +Foo(); diff --git a/tests/cases/compiler/declFileClassExtendsNull.ts b/tests/cases/compiler/declFileClassExtendsNull.ts new file mode 100644 index 00000000000..d21fd5d3805 --- /dev/null +++ b/tests/cases/compiler/declFileClassExtendsNull.ts @@ -0,0 +1,5 @@ +// @target: ES5 +// @declaration: true + +class ExtendsNull extends null { +} \ No newline at end of file diff --git a/tests/cases/compiler/decoratorMetadataWithConstructorType.ts b/tests/cases/compiler/decoratorMetadataWithConstructorType.ts new file mode 100644 index 00000000000..31c42ee9b43 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithConstructorType.ts @@ -0,0 +1,21 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x: A = new A(); +} diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts new file mode 100644 index 00000000000..8d198e44752 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import {db} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts new file mode 100644 index 00000000000..ac097dd3ba4 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import {db as Database} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: Database; + + constructor(db: Database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts new file mode 100644 index 00000000000..e15570cb5ba --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import db = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { // collision with namespace of external module db + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts new file mode 100644 index 00000000000..d04d1300531 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; // error no default export +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts new file mode 100644 index 00000000000..24934963b3e --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { // collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts new file mode 100644 index 00000000000..2043279c4aa --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import database from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database; + + constructor(db: database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts new file mode 100644 index 00000000000..bbedf61c6df --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; //error + + constructor(db: db.db) { // error + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts new file mode 100644 index 00000000000..e3318d813a8 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import database = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database.db; + + constructor(db: database.db) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/excessPropertyErrorsSuppressed.ts b/tests/cases/compiler/excessPropertyErrorsSuppressed.ts new file mode 100644 index 00000000000..21bfee420c1 --- /dev/null +++ b/tests/cases/compiler/excessPropertyErrorsSuppressed.ts @@ -0,0 +1,3 @@ +//@suppressExcessPropertyErrors: true + +var x: { a: string } = { a: "hello", b: 42 }; // No error diff --git a/tests/cases/compiler/forwardRefInEnum.ts b/tests/cases/compiler/forwardRefInEnum.ts new file mode 100644 index 00000000000..97bc1819d7b --- /dev/null +++ b/tests/cases/compiler/forwardRefInEnum.ts @@ -0,0 +1,13 @@ +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} diff --git a/tests/cases/compiler/missingPropertiesOfClassExpression.ts b/tests/cases/compiler/missingPropertiesOfClassExpression.ts new file mode 100644 index 00000000000..a1d91355365 --- /dev/null +++ b/tests/cases/compiler/missingPropertiesOfClassExpression.ts @@ -0,0 +1,5 @@ +class George extends class { reset() { return this.y; } } { + constructor() { + super(); + } +} diff --git a/tests/cases/compiler/moduleResolutionNoResolve.ts b/tests/cases/compiler/moduleResolutionNoResolve.ts new file mode 100644 index 00000000000..aea0208b5d6 --- /dev/null +++ b/tests/cases/compiler/moduleResolutionNoResolve.ts @@ -0,0 +1,8 @@ +// @module:commonjs +// @noResolve: true + +// @filename: a.ts +import a = require('./b'); + +// @filename: b.ts +export var c = ''; diff --git a/tests/cases/compiler/nodeResolution1.ts b/tests/cases/compiler/nodeResolution1.ts new file mode 100644 index 00000000000..19316ef251b --- /dev/null +++ b/tests/cases/compiler/nodeResolution1.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: a.ts +export var x = 1; + +// @filename: b.ts +import y = require("./a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution2.ts b/tests/cases/compiler/nodeResolution2.ts new file mode 100644 index 00000000000..9d1972c7239 --- /dev/null +++ b/tests/cases/compiler/nodeResolution2.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a.d.ts +export var x: number; + +// @filename: b.ts +import y = require("a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution3.ts b/tests/cases/compiler/nodeResolution3.ts new file mode 100644 index 00000000000..ede8f76dbbe --- /dev/null +++ b/tests/cases/compiler/nodeResolution3.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/b/index.d.ts +export var x: number; + +// @filename: a.ts +import y = require("b"); \ No newline at end of file diff --git a/tests/cases/compiler/out-flag2.ts b/tests/cases/compiler/out-flag2.ts new file mode 100644 index 00000000000..d3349563a9f --- /dev/null +++ b/tests/cases/compiler/out-flag2.ts @@ -0,0 +1,11 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: commonjs +// @outFile: c.js + +// @Filename: a.ts +class A { } + +// @Filename: b.ts +class B { } \ No newline at end of file diff --git a/tests/cases/compiler/out-flag3.ts b/tests/cases/compiler/out-flag3.ts new file mode 100644 index 00000000000..cb3c6819811 --- /dev/null +++ b/tests/cases/compiler/out-flag3.ts @@ -0,0 +1,14 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: commonjs +// @outFile: c.js +// @out: d.js + +// --out and --outFile error + +// @Filename: a.ts +class A { } + +// @Filename: b.ts +class B { } \ No newline at end of file diff --git a/tests/cases/compiler/recursiveTupleTypes1.ts b/tests/cases/compiler/recursiveTupleTypes1.ts new file mode 100644 index 00000000000..82559eccfad --- /dev/null +++ b/tests/cases/compiler/recursiveTupleTypes1.ts @@ -0,0 +1,12 @@ +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree1]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/cases/compiler/recursiveTupleTypes2.ts b/tests/cases/compiler/recursiveTupleTypes2.ts new file mode 100644 index 00000000000..78c8efa82a4 --- /dev/null +++ b/tests/cases/compiler/recursiveTupleTypes2.ts @@ -0,0 +1,12 @@ +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree2]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts new file mode 100644 index 00000000000..cffb7654834 --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts @@ -0,0 +1,7 @@ +type TreeNode = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNode[]; +nodes.map(n => n.name); diff --git a/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts new file mode 100644 index 00000000000..4ca5c9fc663 --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts @@ -0,0 +1,12 @@ +type TreeNode = { + name: string; + parent: TreeNode; +} + +type TreeNodeMiddleman = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNodeMiddleman[]; +nodes.map(n => n.name); diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts index 1b1e3cfab6c..f72845c18a4 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts @@ -1,8 +1,8 @@ -// In the true branch statement of an ‘if’ statement, -// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an ‘if’ statement, -// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { if (typeof x === "string") { diff --git a/tests/cases/conformance/jsx/tsxReactEmit5.tsx b/tests/cases/conformance/jsx/tsxReactEmit5.tsx new file mode 100644 index 00000000000..c961a23ecfc --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit5.tsx @@ -0,0 +1,20 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: test.d.ts +export var React; + +//@filename: react-consumer.tsx +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit6.tsx b/tests/cases/conformance/jsx/tsxReactEmit6.tsx new file mode 100644 index 00000000000..2782f90e503 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit6.tsx @@ -0,0 +1,22 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: react-consumer.tsx +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} diff --git a/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx new file mode 100644 index 00000000000..4b7dc5780f8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +
Dot goes here: · ¬AnEntity;
; diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx new file mode 100644 index 00000000000..964064979ec --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx @@ -0,0 +1,17 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// Emit ' word' in the last string +
word code word
; +// Same here +
code word
; +// And here +
word
; + diff --git a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts index d7ccbe73f33..5a8f661789c 100644 --- a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts +++ b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts @@ -24,7 +24,7 @@ goTo.marker('1'); verify.quickInfoIs('var c: {\n name: string;\n age: number;\n}[]'); goTo.marker('2'); -verify.quickInfoIs('var c1: ({\n name: string;\n age: number;\n} | {\n name: string;\n age: number;\n dob: Date;\n})[]'); +verify.quickInfoIs('var c1: {\n name: string;\n age: number;\n}[]'); goTo.marker('3'); verify.quickInfoIs('var c2: ({\n\ diff --git a/tests/cases/fourslash/completionEntryForUnionProperty2.ts b/tests/cases/fourslash/completionEntryForUnionProperty2.ts index aa5bc40b5e3..c2d7bc406a5 100644 --- a/tests/cases/fourslash/completionEntryForUnionProperty2.ts +++ b/tests/cases/fourslash/completionEntryForUnionProperty2.ts @@ -1,12 +1,12 @@ /// ////interface One { -//// commonProperty: number; +//// commonProperty: string; //// commonFunction(): number; ////} //// ////interface Two { -//// commonProperty: string +//// commonProperty: number; //// commonFunction(): number; ////} //// @@ -16,5 +16,5 @@ goTo.marker(); verify.memberListContains("toString", "(method) toString(): string"); -verify.memberListContains("valueOf", "(method) valueOf(): number | string"); +verify.memberListContains("valueOf", "(method) valueOf(): string | number"); verify.memberListCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts new file mode 100644 index 00000000000..5424c8e79fa --- /dev/null +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -0,0 +1,62 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @/*1*/ */ +////var v1; +//// +/////** @p/*2*/ */ +////var v2; +//// +/////** @param /*3*/ */ +////var v3; +//// +/////** @param { n/*4*/ } bar */ +////var v4; +//// +/////** @type { n/*5*/ } */ +////var v5; +//// +////// @/*6*/ +////var v6; +//// +////// @pa/*7*/ +////var v7; +//// +/////** @param { n/*8*/ } */ +////var v8; +//// +/////** @return { n/*9*/ } */ +////var v9; + +goTo.marker('1'); +verify.completionListContains("constructor"); +verify.completionListContains("param"); +verify.completionListContains("type"); + +goTo.marker('2'); +verify.completionListContains("constructor"); +verify.completionListContains("param"); +verify.completionListContains("type"); + +goTo.marker('3'); +verify.completionListIsEmpty(); + +goTo.marker('4'); +verify.completionListContains('number'); + +goTo.marker('5'); +verify.completionListContains('number'); + +goTo.marker('6'); +verify.completionListIsEmpty(); + +goTo.marker('7'); +verify.completionListIsEmpty(); + +goTo.marker('8'); +verify.completionListContains('number'); + +goTo.marker('9'); +verify.completionListContains('number'); + diff --git a/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts new file mode 100644 index 00000000000..f8afcdc418c --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts @@ -0,0 +1,18 @@ +/// + +////var C0 = class D {} +////var C3 = class D{} +////var C5 = class D{} + +goTo.marker("0"); +verify.completionListIsEmpty(); +goTo.marker("1"); +verify.completionListIsEmpty(); +goTo.marker("2"); +verify.completionListIsEmpty(); +goTo.marker("3"); +verify.completionListIsEmpty(); +goTo.marker("4"); +verify.not.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts new file mode 100644 index 00000000000..e6017eedbfc --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts @@ -0,0 +1,17 @@ +/// + +////type List1 = T[]; +////type List4 = /*2*/T[]; +////type List3 = /*3*/; + +goTo.marker("0"); +verify.completionListIsEmpty(); +goTo.marker("1"); +verify.not.completionListIsEmpty(); +goTo.marker("2"); +verify.completionListContains("T"); +goTo.marker("3"); +verify.not.completionListIsEmpty(); +verify.not.completionListContains("T"); +verify.completionListContains("T1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts new file mode 100644 index 00000000000..80a910da798 --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts @@ -0,0 +1,19 @@ +/// + +////type Map1 = []; +////type Map1 = /*2*/[]; +////type Map1 = + +////async function asyncFunction() {/*asyncKeyword*/ +//// await +/////*awaitExpressionIndent*/ +//// Promise.resolve("await");/*awaitExpressionAutoformat*/ +//// return await Promise.resolve("completed");/*awaitKeyword*/ +////} + +format.document(); + +goTo.marker("asyncKeyword"); +verify.currentLineContentIs("async function asyncFunction() {"); +goTo.marker("awaitExpressionIndent"); +verify.indentationIs(8); +goTo.marker("awaitExpressionAutoformat"); +verify.currentLineContentIs(' Promise.resolve("await");'); +goTo.marker("awaitKeyword"); +verify.currentLineContentIs(' return await Promise.resolve("completed");'); \ No newline at end of file diff --git a/tests/cases/fourslash/formatFunctionAndConstructorType.ts b/tests/cases/fourslash/formatFunctionAndConstructorType.ts new file mode 100644 index 00000000000..1b9655143f9 --- /dev/null +++ b/tests/cases/fourslash/formatFunctionAndConstructorType.ts @@ -0,0 +1,32 @@ +/// + +////function renderElement( +//// element: Element, +//// renderNode: +////(/*funcAutoformat*/ +//// node: Node/*funcParamAutoformat*/ +/////*funcIndent*/ +//// ) => void, +////newNode: +////new(/*constrAutoformat*/ +//// name: string/*constrParamAutoformat*/ +/////*constrIndent*/ +////) => Node +////): void { +////} + +format.document(); + +goTo.marker("funcAutoformat"); +verify.currentLineContentIs(" ("); +goTo.marker("funcParamAutoformat"); +verify.currentLineContentIs(" node: Node"); +goTo.marker("funcIndent"); +verify.indentationIs(12); + +goTo.marker("constrAutoformat"); +verify.currentLineContentIs(" new ("); +goTo.marker("constrParamAutoformat"); +verify.currentLineContentIs(" name: string"); +goTo.marker("constrIndent"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/formatParameter.ts b/tests/cases/fourslash/formatParameter.ts new file mode 100644 index 00000000000..827de0edf58 --- /dev/null +++ b/tests/cases/fourslash/formatParameter.ts @@ -0,0 +1,23 @@ +/// + +////function foo( +//// first: +//// number,/*first*/ +//// second: ( +//// string/*second*/ +//// ), +//// third: +//// ( +//// boolean/*third*/ +//// ) +////) { +////} + +format.document(); + +goTo.marker("first"); +verify.currentLineContentIs(" number,"); +goTo.marker("second"); +verify.currentLineContentIs(" string"); +goTo.marker("third"); +verify.currentLineContentIs(" boolean"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatSignatures.ts b/tests/cases/fourslash/formatSignatures.ts new file mode 100644 index 00000000000..f850ab48ef9 --- /dev/null +++ b/tests/cases/fourslash/formatSignatures.ts @@ -0,0 +1,31 @@ +/// + +////type Foo = { +//// ( +//// call: any/*callAutoformat*/ +/////*callIndent*/ +//// ): void; +//// new ( +//// constr: any/*constrAutoformat*/ +/////*constrIndent*/ +//// ): void; +//// method( +//// whatever: any/*methodAutoformat*/ +/////*methodIndent*/ +//// ): void; +////}; + +format.document(); + +goTo.marker("callAutoformat"); +verify.currentLineContentIs(" call: any"); +goTo.marker("callIndent"); +verify.indentationIs(8); +goTo.marker("constrAutoformat"); +verify.currentLineContentIs(" constr: any"); +goTo.marker("constrIndent"); +verify.indentationIs(8); +goTo.marker("methodAutoformat"); +verify.currentLineContentIs(" whatever: any"); +goTo.marker("methodIndent"); +verify.indentationIs(8); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTemplateLiteral.ts b/tests/cases/fourslash/formatTemplateLiteral.ts index a1f5ef963da..6d1352fcf0d 100644 --- a/tests/cases/fourslash/formatTemplateLiteral.ts +++ b/tests/cases/fourslash/formatTemplateLiteral.ts @@ -2,6 +2,12 @@ ////var x = `sadasdasdasdasfegsfd /////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `; ////var y = `1${2}/*2*/3`; +////let z= `foo`/*3*/ +////let w= `bar${3}`/*4*/ +////String.raw +//// `template`/*5*/ +////String.raw`foo`/*6*/ +////String.raw `bar${3}`/*7*/ goTo.marker("1"); @@ -10,4 +16,21 @@ edit.insert("\r\n"); // edit will trigger formatting - should succeeed goTo.marker("2"); edit.insert("\r\n"); verify.indentationIs(0); -verify.currentLineContentIs("3`;") \ No newline at end of file +verify.currentLineContentIs("3`;") + +goTo.marker("3"); +edit.insert(";"); +verify.currentLineContentIs("let z = `foo`;"); +goTo.marker("4"); +edit.insert(";"); +verify.currentLineContentIs("let w = `bar${3}`;"); + +goTo.marker("5"); +edit.insert(";"); +verify.currentLineContentIs(" `template`;"); +goTo.marker("6"); +edit.insert(";"); +verify.currentLineContentIs("String.raw `foo`;"); +goTo.marker("7"); +edit.insert(";"); +verify.currentLineContentIs("String.raw `bar${3}`;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTypeAlias.ts b/tests/cases/fourslash/formatTypeAlias.ts new file mode 100644 index 00000000000..c97a868c1f1 --- /dev/null +++ b/tests/cases/fourslash/formatTypeAlias.ts @@ -0,0 +1,14 @@ +/// + +////type Alias = /*typeKeyword*/ +/////*indent*/ +////number;/*autoformat*/ + +format.document(); + +goTo.marker("typeKeyword"); +verify.currentLineContentIs("type Alias ="); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" number;"); diff --git a/tests/cases/fourslash/formatTypeUnion.ts b/tests/cases/fourslash/formatTypeUnion.ts new file mode 100644 index 00000000000..267ba656612 --- /dev/null +++ b/tests/cases/fourslash/formatTypeUnion.ts @@ -0,0 +1,14 @@ +/// + +////type Union = number | {}/*formatOperator*/ +/////*indent*/ +////|string/*autoformat*/ + +format.document(); + +goTo.marker("formatOperator"); +verify.currentLineContentIs("type Union = number | {}"); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" | string"); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputOutFile.ts b/tests/cases/fourslash/getEmitOutputOutFile.ts new file mode 100644 index 00000000000..4a9439737ea --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputOutFile.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputOutFile.baseline +// @declaration: true +// @outFile: outFile.js + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts b/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts new file mode 100644 index 00000000000..19eda2ad111 --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputTsxFile_Preserve.baseline +// @declaration: true +// @sourceMap: true +// @jsx: preserve + +// @Filename: inputFile1.ts +// @emitThisFile: true +////// regular ts file +//// var t: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.tsx +// @emitThisFile: true +//// var y = "my div"; +//// var x =
+ +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_React.ts b/tests/cases/fourslash/getEmitOutputTsxFile_React.ts new file mode 100644 index 00000000000..ccfa3bcc0c2 --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputTsxFile_React.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputTsxFile_React.baseline +// @declaration: true +// @sourceMap: true +// @jsx: react + +// @Filename: inputFile1.ts +// @emitThisFile: true +////// regular ts file +//// var t: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.tsx +// @emitThisFile: true +//// var y = "my div"; +//// var x =
+ +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts new file mode 100644 index 00000000000..5444ab9acdd --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts @@ -0,0 +1,56 @@ +/// + +////var x = class C { +//// public x; +//// public y; +//// public z; +//// public staticX; +//// constructor() { +//// this; +//// this.x; +//// this.y; +//// this.z; +//// } +//// foo() { +//// this; +//// () => this; +//// () => { +//// if (this) { +//// this; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// return this.x; +//// } +//// +//// static bar() { +//// [|this|]; +//// [|this|].staticX; +//// () => [|this|]; +//// () => { +//// if ([|this|]) { +//// [|this|]; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// } +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts new file mode 100644 index 00000000000..ed8f8cb1d0e --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts @@ -0,0 +1,54 @@ +/// + +////var x = class C { +//// public x; +//// public y; +//// public z; +//// constructor() { +//// [|this|]; +//// [|this|].x; +//// [|this|].y; +//// [|this|].z; +//// } +//// foo() { +//// [|this|]; +//// () => [|this|]; +//// () => { +//// if ([|this|]) { +//// [|this|]; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// return [|this|].x; +//// } +//// +//// static bar() { +//// this; +//// () => this; +//// () => { +//// if (this) { +//// this; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// } +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts new file mode 100644 index 00000000000..aa96400a397 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts @@ -0,0 +1,11 @@ +/// + +////var x = class C { +//// /*definition*/constructor() { +//// var other = new /*usage*/C; +//// } +////} + +goTo.marker("usage"); +goTo.definition(); +verify.caretAtMarker("definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts new file mode 100644 index 00000000000..dc5c362772c --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts @@ -0,0 +1,16 @@ +/// + +////namespace Foo { +//// export var x; +////} +//// +////class Foo { +//// /*definition*/constructor() { +//// } +////} +//// +////var x = new /*usage*/Foo(); + +goTo.marker("usage"); +goTo.definition(); +verify.caretAtMarker("definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts b/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts new file mode 100644 index 00000000000..b6a10e086c2 --- /dev/null +++ b/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts @@ -0,0 +1,44 @@ +/// + +////type /*0*/List = /*2*/T[] +////type /*3*/List2 = /*5*/T[]; + +type List2 = T[]; + +type L = T[] +let typeAliashDisplayParts = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List", kind: "aliasName" }, + { text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: ">", kind: "punctuation" }]; + +let typeAliashDisplayParts2 = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List2", kind: "aliasName" }, + { text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "extends", kind: "keyword" }, + { text: " ", kind: "space" }, { text: "string", kind: "keyword" }, { text: ">", kind: "punctuation" }]; + +let typeParameterDisplayParts = [{ text: "(", kind: "punctuation" }, { text: "type parameter", kind: "text" }, { text: ")", kind: "punctuation" }, { text: " ", kind: "space" }, + { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "in", kind: "keyword" }, { text: " ", kind: "space" } ] + + +goTo.marker('0'); +verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("0").position, length: "List".length }, + typeAliashDisplayParts.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" }, + { text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []); + +goTo.marker('1'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("1").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts), []); + +goTo.marker('2'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("2").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts), []); + +goTo.marker('3'); +verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("3").position, length: "List2".length }, + typeAliashDisplayParts2.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" }, + { text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []); + +goTo.marker('4'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("4").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts2), []); + +goTo.marker('5'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("5").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts2), []); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationClassExpression.ts b/tests/cases/fourslash/semanticClassificationClassExpression.ts new file mode 100644 index 00000000000..f067265df29 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationClassExpression.ts @@ -0,0 +1,12 @@ +/// + +//// var x = class /*0*/C {} +//// class /*1*/C {} +//// class /*2*/D extends class /*3*/B{} { } +var c = classification; +verify.semanticClassificationsAre( + c.className("C", test.marker("0").position), + c.className("C", test.marker("1").position), + c.className("D", test.marker("2").position), + c.className("B", test.marker("3").position) +); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts index 3931433e51f..2cfd27f2e3b 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts @@ -12,6 +12,6 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): voi verifyIndentationAfterNewLine("1", 4); verifyIndentationAfterNewLine("2", 4); verifyIndentationAfterNewLine("3", 4); -verifyIndentationAfterNewLine("4", 4); +verifyIndentationAfterNewLine("4", 8); verifyIndentationAfterNewLine("5", 4); verifyIndentationAfterNewLine("6", 4); \ No newline at end of file diff --git a/tests/cases/fourslash/tsxRename5.ts b/tests/cases/fourslash/tsxRename5.ts new file mode 100644 index 00000000000..cc18d6287c3 --- /dev/null +++ b/tests/cases/fourslash/tsxRename5.ts @@ -0,0 +1,20 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class MyClass { +//// props: { +//// name?: string; +//// size?: number; +//// } +//// +//// var [|nn|]: string; +//// var x = ; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts new file mode 100644 index 00000000000..0917e72f1ce --- /dev/null +++ b/tests/cases/unittests/moduleResolution.ts @@ -0,0 +1,221 @@ +/// +/// + +declare namespace chai.assert { + function deepEqual(actual: any, expected: any): void; +} + +module ts { + + interface File { + name: string + content?: string + } + + function createModuleResolutionHost(...files: File[]): ModuleResolutionHost { + let map = arrayToMap(files, f => f.name); + + return { fileExists, readFile }; + + function fileExists(path: string): boolean { + return hasProperty(map, path); + } + + function readFile(path: string): string { + return hasProperty(map, path) ? map[path].content : undefined; + } + } + + function splitPath(path: string): { dir: string; rel: string } { + let index = path.indexOf(directorySeparator); + return index === -1 + ? { dir: path, rel: undefined } + : { dir: path.substr(0, index), rel: path.substr(index + 1) }; + } + + describe("Node module resolution - relative paths", () => { + + function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void { + for (let ext of supportedExtensions) { + let containingFile = { name: containingFileName } + let moduleFile = { name: moduleFileNameNoExt + ext } + let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + + let failedLookupLocations: string[] = []; + let dir = getDirectoryPath(containingFileName); + for (let e of supportedExtensions) { + if (e === ext) { + break; + } + else { + failedLookupLocations.push(normalizePath(getRootLength(moduleName) === 0 ? combinePaths(dir, moduleName) : moduleName) + e); + } + } + + assert.deepEqual(resolution.failedLookupLocations, failedLookupLocations); + } + } + + it("module name that starts with './' resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo/bar/foo", "./foo"); + }); + + it("module name that starts with '../' resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo/foo", "../foo"); + }); + + it("module name that starts with '/' script extension resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo", "/foo"); + }); + + it("module name that starts with 'c:/' script extension resolved as relative file name", () => { + testLoadAsFile("c:/foo/bar/baz.ts", "c:/foo", "c:/foo"); + }); + + function testLoadingFromPackageJson(containingFileName: string, packageJsonFileName: string, fieldRef: string, moduleFileName: string, moduleName: string): void { + let containingFile = { name: containingFileName }; + let packageJson = { name: packageJsonFileName, content: JSON.stringify({ "typings": fieldRef }) }; + let moduleFile = { name: moduleFileName }; + let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + // expect three failed lookup location - attempt to load module as file with all supported extensions + assert.equal(resolution.failedLookupLocations.length, 3); + } + + it("module name as directory - load from typings", () => { + testLoadingFromPackageJson("/a/b/c/d.ts", "/a/b/c/bar/package.json", "c/d/e.d.ts", "/a/b/c/bar/c/d/e.d.ts", "./bar"); + testLoadingFromPackageJson("/a/b/c/d.ts", "/a/bar/package.json", "e.d.ts", "/a/bar/e.d.ts", "../../bar"); + testLoadingFromPackageJson("/a/b/c/d.ts", "/bar/package.json", "e.d.ts", "/bar/e.d.ts", "/bar"); + testLoadingFromPackageJson("c:/a/b/c/d.ts", "c:/bar/package.json", "e.d.ts", "c:/bar/e.d.ts", "c:/bar"); + }); + + it ("module name as directory - load index.d.ts", () => { + let containingFile = {name: "/a/b/c.ts"}; + let packageJson = {name: "/a/b/foo/package.json", content: JSON.stringify({main: "/c/d"})}; + let indexFile = { name: "/a/b/foo/index.d.ts" }; + let resolution = nodeModuleNameResolver("./foo", containingFile.name, createModuleResolutionHost(containingFile, packageJson, indexFile)); + assert.equal(resolution.resolvedFileName, indexFile.name); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/b/foo.ts", + "/a/b/foo.tsx", + "/a/b/foo.d.ts", + "/a/b/foo/index.ts", + "/a/b/foo/index.tsx", + ]); + }); + }); + + describe("Node module resolution - non-relative paths", () => { + it("load module as file - ts files not loaded", () => { + let containingFile = { name: "/a/b/c/d/e.ts" }; + let moduleFile = { name: "/a/b/node_modules/foo.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, undefined); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/b/c/d/node_modules/foo.d.ts", + "/a/b/c/d/node_modules/foo/package.json", + "/a/b/c/d/node_modules/foo/index.d.ts", + "/a/b/c/node_modules/foo.d.ts", + "/a/b/c/node_modules/foo/package.json", + "/a/b/c/node_modules/foo/index.d.ts", + "/a/b/node_modules/foo.d.ts", + "/a/b/node_modules/foo/package.json", + "/a/b/node_modules/foo/index.d.ts", + "/a/node_modules/foo.d.ts", + "/a/node_modules/foo/package.json", + "/a/node_modules/foo/index.d.ts", + "/node_modules/foo.d.ts", + "/node_modules/foo/package.json", + "/node_modules/foo/index.d.ts" + ]) + }); + + it("load module as file", () => { + let containingFile = { name: "/a/b/c/d/e.ts" }; + let moduleFile = { name: "/a/b/node_modules/foo.d.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + }); + + it("load module as directory", () => { + let containingFile = { name: "/a/node_modules/b/c/node_modules/d/e.ts" }; + let moduleFile = { name: "/a/node_modules/foo/index.d.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/foo/package.json", + "/a/node_modules/b/c/node_modules/foo/index.d.ts", + "/a/node_modules/b/node_modules/foo.d.ts", + "/a/node_modules/b/node_modules/foo/package.json", + "/a/node_modules/b/node_modules/foo/index.d.ts", + "/a/node_modules/foo.d.ts", + "/a/node_modules/foo/package.json" + ]); + }); + }); + + describe("BaseUrl mode", () => { + + it ("load module as relative url", () => { + function test(containingFileName: string, moduleFileName: string, moduleName: string): void { + let containingFile = {name: containingFileName }; + let moduleFile = { name: moduleFileName }; + let resolution = baseUrlModuleNameResolver(moduleName, containingFile.name, "", createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + let expectedFailedLookupLocations: string[] = []; + + let moduleNameHasExt = forEach(supportedExtensions, e => fileExtensionIs(moduleName, e)); + if (!moduleNameHasExt) { + let dir = getDirectoryPath(containingFileName); + + // add candidates with extensions that precede extension of the actual module name file in the list of supportd extensions + for (let ext of supportedExtensions) { + + let hasExtension = ext !== ".ts" + ? fileExtensionIs(moduleFileName, ext) + : fileExtensionIs(moduleFileName, ".ts") && !fileExtensionIs(moduleFileName, ".d.ts"); + + if (hasExtension) { + break; + } + else { + expectedFailedLookupLocations.push(normalizePath(combinePaths(dir, moduleName + ext))); + } + } + } + + assert.deepEqual(resolution.failedLookupLocations, expectedFailedLookupLocations) + } + + test("/a/b/c/d.ts", "/foo.ts", "/foo"); + test("/a/b/c/d.ts", "/foo.d.ts", "/foo"); + test("/a/b/c/d.ts", "/foo.tsx", "/foo"); + + test("/a/b/c/d.ts", "/a/b/c/foo.ts", "./foo"); + test("/a/b/c/d.ts", "/a/b/c/foo.d.ts", "./foo"); + test("/a/b/c/d.ts", "/a/b/c/foo.tsx", "./foo"); + + test("/a/b/c/d.ts", "/a/b/foo.ts", "../foo"); + test("/a/b/c/d.ts", "/a/b/foo.d.ts", "../foo"); + test("/a/b/c/d.ts", "/a/b/foo.tsx", "../foo"); + }); + + it ("load module using base url", () => { + function test(containingFileName: string, moduleFileName: string, moduleName: string, baseUrl: string): void { + let containingFile = { name: containingFileName }; + let moduleFile = { name: moduleFileName }; + let resolution = baseUrlModuleNameResolver(moduleName, containingFileName, baseUrl, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + } + + test("/a/base/c/d.ts", "/a/base/c/d/e.ts", "c/d/e", "/a/base"); + test("/a/base/c/d.ts", "/a/base/c/d/e.d.ts", "c/d/e", "/a/base"); + test("/a/base/c/d.ts", "/a/base/c/d/e.tsx", "c/d/e", "/a/base"); + }); + }); +} \ No newline at end of file diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index b3806c4f675..0b87910d26e 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -23,6 +23,13 @@ module ts { function test(input: string, testSettings: TranspileTestSettings): void { let transpileOptions: TranspileOptions = testSettings.options || {}; + if (!transpileOptions.compilerOptions) { + transpileOptions.compilerOptions = {}; + } + if(transpileOptions.compilerOptions.newLine === undefined) { + // use \r\n as default new line + transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } let canUseOldTranspile = !transpileOptions.renamedDependencies; @@ -213,6 +220,55 @@ var x = 0;`, expectedOutput: output }); }); + + it("Transpile with emit decorators and emit metadata", () => { + let input = + `import {db} from './db';\n` + + `function someDecorator(target) {\n` + + ` return target;\n` + + `} \n` + + `@someDecorator\n` + + `class MyClass {\n` + + ` db: db;\n` + + ` constructor(db: db) {\n` + + ` this.db = db;\n` + + ` this.db.doSomething(); \n` + + ` }\n` + + `}\n` + + `export {MyClass}; \n` + let output = + `var db_1 = require(\'./db\');\n` + + `function someDecorator(target) {\n` + + ` return target;\n` + + `}\n` + + `var MyClass = (function () {\n` + + ` function MyClass(db) {\n` + + ` this.db = db;\n` + + ` this.db.doSomething();\n` + + ` }\n` + + ` MyClass = __decorate([\n` + + ` someDecorator, \n` + + ` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` + + ` ], MyClass);\n` + + ` return MyClass;\n` + + ` var _a;\n` + + `})();\n` + + `exports.MyClass = MyClass;\n`; + test(input, + { + options: { + compilerOptions: { + module: ModuleKind.CommonJS, + newLine: NewLineKind.LineFeed, + noEmitHelpers: true, + emitDecoratorMetadata: true, + experimentalDecorators: true, + target: ScriptTarget.ES5, + } + }, + expectedOutput: output + }); + }); }); }